JDK-8303069 : Memory leak in CompilerOracle::parse_from_line
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 17,20,21
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-02-22
  • Updated: 2023-05-04
  • Resolved: 2023-03-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17 JDK 20 JDK 21
17.0.8-oracleFixed 20.0.2Fixed 21 b15Fixed
Related Reports
Relates :  
Description
Direct leak of 56 byte(s) in 1 object(s) allocated from:                                                                                                                                                                                                                                    
    #0 0x7f312f8b89cf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69                                                                                                                                                                                    
    #1 0x7f312beaefbf in os::malloc(unsigned long, MEMFLAGS, NativeCallStack const&) src/hotspot/share/runtime/os.cpp:654                                                                                                                                                                   
    #2 0x7f3129a1dd17 in AllocateHeap(unsigned long, MEMFLAGS, NativeCallStack const&, AllocFailStrategy::AllocFailEnum) src/hotspot/share/memory/allocation.cpp:42                                                                                                                         
    #3 0x7f3129a1dd17 in AllocateHeap(unsigned long, MEMFLAGS, AllocFailStrategy::AllocFailEnum) src/hotspot/share/memory/allocation.cpp:52                                                                                                                                                 
    #4 0x7f312a467c9e in CHeapObjBase::operator new(unsigned long, MEMFLAGS) src/hotspot/share/memory/allocation.hpp:183                                                                                                                                                                    
    #5 0x7f312a467c9e in CHeapObj<(MEMFLAGS)7>::operator new(unsigned long) src/hotspot/share/memory/allocation.hpp:237                                                                                                                                                                     
    #6 0x7f312a467c9e in TypedMethodOptionMatcher::clone() src/hotspot/share/compiler/compilerOracle.cpp:246                                                                                                                                                                                
    #7 0x7f312a46a95e in CompilerOracle::parse_from_line(char*) src/hotspot/share/compiler/compilerOracle.cpp:867                                                                                                                                                                           
    #8 0x7f312a46dec1 in CompilerOracle::parse_from_string(char const*, void (*)(char*)) src/hotspot/share/compiler/compilerOracle.cpp:989                                                                                                                                                  
    #9 0x7f312a46dec1 in compilerOracle_init() src/hotspot/share/compiler/compilerOracle.cpp:993                                                                                                                                                                                            
    #10 0x7f312ae59bd8 in init_globals() src/hotspot/share/runtime/init.cpp:156                                                                                                                                                                                                             
    #11 0x7f312c89b1b7 in Threads::create_vm(JavaVMInitArgs*, bool*) src/hotspot/share/runtime/threads.cpp:568                                                                                                                                                                              
    #12 0x7f312b24c353 in JNI_CreateJavaVM_inner src/hotspot/share/prims/jni.cpp:3588                                                                                                                                                                                                       
    #13 0x7f312b24c353 in JNI_CreateJavaVM src/hotspot/share/prims/jni.cpp:3674                                                                                                                                                                                                             
    #14 0x7f312f7bfe25 in InitializeJVM src/java.base/share/native/libjli/java.c:1459                                                                                                                                                                                                       
    #15 0x7f312f7bfe25 in JavaMain src/java.base/share/native/libjli/java.c:413                                                                                                                                                                                                             
    #16 0x7f312f7c8708 in ThreadJavaMain src/java.base/unix/native/libjli/java_md.c:650                                                                                                                                                                                                     
    #17 0x7f312f65afd3 in start_thread nptl/pthread_create.c:442
Comments
Fix request [17u] I backport this for parity with 17.0.8-oracle. Low risk, trivial change. Clean backport. SAP nightly testing passed.
03-05-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/1310 Date: 2023-04-28 11:29:43 +0000
28-04-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk20u/pull/48 Date: 2023-04-04 13:26:20 +0000
04-04-2023

Fix Request (JDK 20u) Fixes a memory leak. The fix is low risk, was already backported to Oracle JDK 17u and tested in the JDK 21 and 17u CIs. The backport applies cleanly.
04-04-2023

Changeset: 384a8b85 Author: Damon Fenacci <damon.fenacci@oracle.com> Committer: Tobias Hartmann <thartmann@openjdk.org> Date: 2023-03-17 13:24:55 +0000 URL: https://git.openjdk.org/jdk/commit/384a8b85a7266b920242ea73baf578577ca588ec
17-03-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/13060 Date: 2023-03-16 14:08:13 +0000
16-03-2023

The issue is indeed due to the blackhole compile command without enabling UnlockExperimentalVMOptions. We bail out but never delete the option and don't add it to the list (register_command in compilerOracle.cpp:312)
16-03-2023

FYI It is reported during the test `compiler/blackhole/BlackholeExperimentalUnlockTest.java`. Based on the stderr `OpenJDK 64-Bit Server VM warning: Blackhole compile option is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions` I think you are correct in that there is an error and it leaks the memory.
23-02-2023

Ah, maybe it's when there's a parse error and we bail out. In that case, the VM will only print a warning and not exit.
23-02-2023

[~jcking], do you know why lsan thinks that there is a leak? Maybe I'm missing something.
23-02-2023

I quickly had a look at the code and I'm not sure if there is really a leak. While parsing the CompileCommand, a TypedMethodOptionMatcher is cloned and added to a linked list in register_command. That list is live and reachable via the option_list field during the entire lifetime of the VM. ILW = Potential (benign) memory leak when parsing CompileCommands, with CompileCommands, no workaround = MLH = P4
23-02-2023