RFR: 8364735: [asan] heap-use-after-free error detected in defaultStream::writer during VM shutdown

David Holmes dholmes at openjdk.org
Wed Aug 20 02:39:39 UTC 2025


On Tue, 19 Aug 2025 08:59:18 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> `ostream_exit` was deleting the stream underlying the `xtty` prior to nulling the `xtty` global variable, resulting in a use-after-free-error. Due to races during VM shutdown we cannot make use of `xtty` perfectly safe, but we can certainly narrow the window during which use-after-free is possible.
>> 
>> Testing:
>>  - tiers 1-3 sanity
>> 
>> Thanks
>
> src/hotspot/share/utilities/ostream.cpp line 1001:
> 
>> 999:   xtty = nullptr;
>> 1000:   OrderAccess::fence(); // force visibility to concurrently executing threads
>> 1001:   delete ds;
> 
> There are lots of places in the VM that don't even try to clean up on VM exit. I think we even talk
> about non-cleanup on exit in the style guide. So why are we doing this cleanup, in such a potentially
> sensitive/fragile area?

Because we are flushing and closing the output streams so their content will be made available.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/26832#discussion_r2286836368


More information about the hotspot-dev mailing list