|
43 | 43 | // can be still accessed concurrently during VM termination |
44 | 44 | Profiler *const Profiler::_instance = new Profiler(); |
45 | 45 | volatile bool Profiler::_signals_initialized = false; |
| 46 | +volatile bool Profiler::_need_JDK_8313796_workaround = true; |
46 | 47 |
|
47 | 48 | static void (*orig_trapHandler)(int signo, siginfo_t *siginfo, void *ucontext); |
48 | 49 | static void (*orig_segvHandler)(int signo, siginfo_t *siginfo, void *ucontext); |
@@ -917,8 +918,9 @@ bool Profiler::crashHandler(int signo, siginfo_t *siginfo, void *ucontext) { |
917 | 918 |
|
918 | 919 | ddprof::StackWalker::checkFault(thrd); |
919 | 920 |
|
920 | | - // Workaround for JDK-8313796. Setting cstack=dwarf also helps |
921 | | - if (VMStructs::isInterpretedFrameValidFunc((const void *)pc) && |
| 921 | + // Workaround for JDK-8313796 if needed. Setting cstack=dwarf also helps |
| 922 | + if (_need_JDK_8313796_workaround && |
| 923 | + VMStructs::isInterpretedFrameValidFunc((const void *)pc) && |
922 | 924 | frame.skipFaultInstruction()) { |
923 | 925 | if (thrd != nullptr) { |
924 | 926 | thrd->exitCrashHandler(); |
@@ -1101,6 +1103,20 @@ Error Profiler::checkJvmCapabilities() { |
1101 | 1103 | return Error::OK; |
1102 | 1104 | } |
1103 | 1105 |
|
| 1106 | +void Profiler::check_JDK_8313796_workaround() { |
| 1107 | + int java_version = VM::java_version(); |
| 1108 | + int java_update_version = VM::java_update_version(); |
| 1109 | + |
| 1110 | + // JDK-8313796 has been fixed in JDK 22 and backported to |
| 1111 | + // JDK versions 11.0.21, 17.0.9 and 21.0.1 |
| 1112 | + bool fixed_version = java_version >= 22 || |
| 1113 | + (java_version == 11 && java_update_version >= 21) || |
| 1114 | + (java_version == 17 && java_update_version >= 9) || |
| 1115 | + (java_version == 21 && java_update_version >= 1); |
| 1116 | + _need_JDK_8313796_workaround = !fixed_version; |
| 1117 | +} |
| 1118 | + |
| 1119 | + |
1104 | 1120 | Error Profiler::start(Arguments &args, bool reset) { |
1105 | 1121 | MutexLocker ml(_state_lock); |
1106 | 1122 | if (_state > IDLE) { |
|
0 commit comments