RFR(S): 8058897 - Unsafe.reallocateMemory() ignores -XX:MallocMaxTestWords setting.

Daniel D. Daugherty daniel.daugherty at oracle.com
Wed Jan 7 18:27:38 UTC 2015


On 1/7/15 9:26 AM, Christian Tornqvist wrote:
> Hi Dan,
>
>> src/share/vm/runtime/os.cpp
>> The old testMalloc() function would increment cur_malloc_words only
>> if the underlying ::malloc() call succeeded. This was intentional.
>> The switch to has_reached_max_malloc_test_peak() followed by the
>> ::malloc() call means that an intentionally large failing ::malloc()
>> call will result in falsely reaching the test peak.
> The changes necessary to make this work for both our malloc and realloc
> implementations would bloat the code quite a bit.
>
> I looked through all uses of MallocMaxTestWords, and there are only 5 tests
> using this flag, including the one I'm including in this webrev.
> None of them does a large allocation assuming it would fail and not
> increment the cur_malloc_words.

I'm OK with evolving this testing option in this direction.

Not for this bug fix, but do you have something in mind to
solve the issue where cur_malloc_words is only incremented
and never decremented? Ron and I couldn't think of a solution
when he original implemented MallocMaxTestWords.


>
>> test/runtime/Unsafe/Reallocate.java
>> Should this test have an @bug entry?
> I'll add this
>
>> line 59: unsafe.reallocateMemory(address, 20 * 1000 * 1000 * 8);
>> Shouldn't this be "1024 * 1024" instead of "1000 * 1000"?
> Good catch, fixing this.
>
>> Also, -XX:MallocMaxTestWords=20m means 20m words and not
>> 20m bytes so the "* 8" part might not always cause an OOM.
> Words are either 4 or 8 bytes, which means that the size passed onto
> reallocateMemory() will be equal to 20m words on 64bit and 40m on 32bit.
>
> Updated webrev can be found at:
> http://cr.openjdk.java.net/~ctornqvi/webrev/8058897/webrev.01/

Thumbs up on the latest version.

Dan


>
>
> Thanks,
> Christian
>
> -----Original Message-----
> From: Daniel D. Daugherty [mailto:daniel.daugherty at oracle.com]
> Sent: Wednesday, January 7, 2015 9:47 AM
> To: Christian Tornqvist
> Cc: 'hotspot-runtime-dev'
> Subject: Re: RFR(S): 8058897 - Unsafe.reallocateMemory() ignores
> -XX:MallocMaxTestWords setting.
>
> On 1/6/15 5:12 PM, Christian Tornqvist wrote:
>> Hi everyone,
>>
>>    
>>
>> This change makes realloc use MallocMaxTestWords, a debug option used
>> to simulate malloc OOM.
>>
>>    
>>
>> Webrev:
>>
>> http://cr.openjdk.java.net/~ctornqvi/webrev/8058897/webrev.00/
> src/share/vm/runtime/os.cpp
>       The old testMalloc() function would increment cur_malloc_words only
>       if the underlying ::malloc() call succeeded. This was intentional.
>       The switch to has_reached_max_malloc_test_peak() followed by the
>       ::malloc() call means that an intentionally large failing ::malloc()
>       call will result in falsely reaching the test peak.
>
>
> test/runtime/Unsafe/Reallocate.java
>       Should this test have an @bug entry?
>
>       line 59: unsafe.reallocateMemory(address, 20 * 1000 * 1000 * 8);
>           Shouldn't this be "1024 * 1024" instead of "1000 * 1000"?
>
>           Also, -XX:MallocMaxTestWords=20m means 20m words and not
>           20m bytes so the "* 8" part might not always cause an OOM.
>
> Dan
>
>
>>    
>>
>> Bug:
>>
>> https://bugs.openjdk.java.net/browse/JDK-8058897
>>
>>    
>>
>> Thanks,
>>
>> Christian
>>
>



More information about the hotspot-runtime-dev mailing list