On Mon, 19 Oct 2026 21:57:39 GMT, Xin Liu <[email protected]> wrote: >> Andrei Pangin has updated the pull request with a new target base due to a >> merge or a rebase. The pull request now contains two commits: >> >> - Re-implemented native frames support using variable-size requests >> - 8392187: JFR: Use-after-free bug in CPU-time profiler can crash JVM > > src/hotspot/share/jfr/recorder/stacktrace/jfrNativeFunctionRepository.cpp > line 192: > >> 190: } >> 191: >> 192: return _main_exe != nullptr ? _main_exe : ""; > > I understand that we can't return nullptr because path will pass to strcmp > later. We could optimize the fast path here. > > _main_exec is nullptr only if os::strdup can't execute malloc (len+1) bytes. > How about we use os::strdup_check_oom at line 189? > > Or we define static char s_zero_ = 0; then we have the following logic. > > if (_main_exe == nullptr) { > _main_exe = &s_zero; > } > > Because _main_exe is leaked anyway, we can assign it a non-allocated pointer. > > if so, we waive the null pointer comparison in library_call.
The edge case you're describing can only happen if `os::strdup` fails due to OOM. If this ever happens, calling `readlink` again during flush is least of the problem. And the current behavior is arguably better, since it retries a transient allocation failure. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/32524#discussion_r4320507376
