-
Notifications
You must be signed in to change notification settings - Fork 7
A crash related to ElfParser::loadSymbolTable #191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @yanglong1010 - great report! Thanks! I see the change was done as a part of #101, probably as a way to placate asan? |
Additional description: My environment is
The libjvm.so of the default JDK 8 installation (apt install openjdk-8-jdk) has no java-profiler/ddprof-lib/src/main/cpp/symbols_linux.cpp Lines 183 to 185 in cc98924
This crash happens if the separate debug info package is installed (apt install openjdk-8-dbg).
java-profiler/ddprof-lib/src/main/cpp/symbols_linux.cpp Lines 183 to 185 in cc98924
If I use other OpenJDK 8 builds like the bellow one, which has
|
Thanks for the careful report. Agreed on the revert. |
Thank you for your confirmation and review. |
Hi,
I encountered a crash today, after some investigation, I think I have found the reason.
I ran java-profiler using the command bellow. Run with Datadog Java agent can trigger this crash too (not tested).
/usr/lib/jvm/java-8-openjdk-amd64/bin/java -agentpath:/root/java-profiler/ddprof-lib/build/lib/main/release/linux/x64/libjavaProfiler.so=start,cpu=10ms,file=/tmp/ap.jfr -cp java Demo (Any Java code can reproduce)
According to the stack trace, there must be something wrong with the VMStructs parsing, J9Ext should not be called on OpenJDK 8.
java-profiler/ddprof-lib/src/main/cpp/vmStructs.cpp
Lines 708 to 714 in cc98924
Debugging with debug build of java-profiler, I found
gHotSpotVMStructs
can not be found, then VMStructs::initOffsets returned in line vmStructs.cpp:164.java-profiler/ddprof-lib/src/main/cpp/vmStructs.cpp
Lines 155 to 165 in cc98924
After further debugging, I found some symbols are skipped in line symbols_linux.cpp:357.
java-profiler/ddprof-lib/src/main/cpp/symbols_linux.cpp
Line 357 in cc98924
java-profiler/ddprof-lib/src/main/cpp/symbols_linux.cpp
Lines 350 to 367 in cc98924
In my case, the symbols are all stripped from libjvm.so, and stored in a separate file, which can be installed via
apt-get install openjdk-8-dbg
.but line symbols_linux.cpp:357 compares the virtual address offset (i.e. sym->st_value, 0xdd82b8 = 14516920) with the debug file size (i.e. 2675232), and obviously, 14516920 is greater than 2675232, then symbol
gHotSpotVMStructs
is skipped.I think the virtual address offset (sym->st_value,) should not be compared with debug file size (_length).
The test does not crash on Java 11, Java 17 and Java 21, but I think It's just a coincidence. The virtual address offset just happens to be smaller than the debug file size on JDK 11, JDK 17 and JDK 21.
I don't know why this check is added. If there is no real example, the simple fix is to remove this check, and I can submit a PR.
Thanks.
The text was updated successfully, but these errors were encountered: