hash policy patch

François Dumont frs.dumont@gmail.com
Wed Aug 31 19:25:00 GMT 2011


On 08/31/2011 11:39 AM, Paolo Carlini wrote:
> Hi,
>>     Looks like there is an unexpected bad_alloc exception. The test 
>> expect one to be generated when the max load factor is set to a very 
>> small value 0.001 but not in any other place. To do so I used the 
>> testsuite __gnu_test::set_memory_limits method and I just discover 
>> that AFAIC see this new test is the first one to use this feature ! 
>> It is documented this way in testsuite_hooks.h:
>>
>> // 2)  set_memory_limits()
>> //   set_memory_limits() uses setrlimit() to restrict dynamic memory
>> //   allocation.  We provide a default memory limit if none is passed 
>> by the
>> //   calling application.  The argument to set_memory_limits() is the
>> //   limit in megabytes (a floating-point number).  If 
>> _GLIBCXX_RES_LIMITS is
>> //   not #defined before including this header, then no limiting is 
>> attempted.
>>
>>     To define _GLIBCXX_RES_LIMITS for the test I use a:
>>
>> // { dg-options "-std=gnu++0x -D_GLIBCXX_RES_LIMITS" }
>>
>>     But in fact defining _GLIBCXX_RES_LIMITS when including this 
>> header is not enough and is even rather useless. This  macro is also 
>> used in testsuite_hooks.cc so it must be defined when this 
>> translation unit is built.  So could you try to run the test again 
>> with this command:
>>
>> make CXXFLAGS=-D_GLIBCXX_RES_LIMITS check
> Actually, I don't think this is the way to go, I'm sorry to not have 
> noticed that earlier. Normally, see, eg, locale/cons/12438.cc, we just 
> call __gnu_test::set_memory_limits, I blindly assumed you followed the 
> existing practice.
>
> I can try to run the patch + testcases with the -D_GLIBCXX_RES_LIMITS 
> removed, but please, in general, be careful to allow for a range of 
> different system, we can't be too strict, generically.
>
> Paolo.
>
I have plan to implement a dedicated allocator that will let me control 
when the bad_alloc exception must be generated. This way I won't have 
portability issue anymore. I will submit the new patch tomorrow.

François



More information about the Libstdc++ mailing list