RFR: 8278125: Some preallocated OOMEs are missing stack trace
David Holmes
dholmes at openjdk.java.net
Fri Dec 3 04:24:14 UTC 2021
On Thu, 2 Dec 2021 12:54:31 GMT, Yi Yang <yyang at openjdk.org> wrote:
> Our customer found that the PreallocatedOutOfMemoryErrorCount is 4 by default. It ought to pre-allocate 4 OOMEs with stack trace, but in fact, no matter how many OOMEs are thrown, only 2 OOMEs have proper stack trace. This is because PreallocatedOutOfMemoryErrorCount is consumed multiple times:
>
> VM tries to allocate a huge object while Java heap is insufficient to accommodate, it goes to:
>
> https://github.com/openjdk/jdk/blob/b79554bb5cef14590d427543a40efbcc60c66548/src/hotspot/share/gc/shared/memAllocator.cpp#L115-L136
>
> Line 135(`Universe::out_of_memory_error_java_heap`->`Universe::gen_out_of_memory_error`) and line 136(`THROW_OOP_`->`Exceptions::_throw`->`Exceptions::count_out_of_memory_exceptions`->`Universe::out_of_memory_error_java_heap`->`Universe::gen_out_of_memory_error`) call `Universe::gen_out_of_memory_error` twice in a single OOM event, which leads this unexpected scenario. Proposed fix is to remove such call in `Exceptions::count_out_of_memory_exceptions`.
>
> Thanks.
Good find!
`count_out_of_memory_exceptions` is obviously confused as to how pre-allocated exceptions work! The logic will not only create new exception objects, consuming the preallocated allotment, but it won't start counting correctly until all the mutable preallocated exceptions are consumed and the default stacktrace-less one is passed in.
I'm not sure about using the strcmp directly in that method though as it requires knowledge of how the strings are defined in universe.cpp. Adding `Universe::is_an_out_of_memory_metaspace(Handle exception)` etc provides better encapsulation.
Thanks,
David
-------------
Changes requested by dholmes (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/6672
More information about the hotspot-runtime-dev
mailing list