diff --git a/.gitignore b/.gitignore index 98ebc2de..7ee56340 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ datadog/maven/resources .history .claude/settings.local.json /jmh-* +build_output.log diff --git a/ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp b/ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp index 3f6b7a0b..6759522e 100644 --- a/ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp +++ b/ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp @@ -16,6 +16,7 @@ SpinLock LibraryPatcher::_lock; const char* LibraryPatcher::_profiler_name = nullptr; PatchEntry LibraryPatcher::_patched_entries[MAX_NATIVE_LIBS]; int LibraryPatcher::_size = 0; +static char _profiler_path[PATH_MAX]; void LibraryPatcher::initialize() { if (_profiler_name == nullptr) { @@ -23,7 +24,11 @@ void LibraryPatcher::initialize() { void* caller_address = __builtin_return_address(0); // Get return address of caller bool ret = dladdr(caller_address, &info); assert(ret); - _profiler_name = realpath(info.dli_fname, nullptr); + _profiler_name = realpath(info.dli_fname, _profiler_path); + if (_profiler_name == nullptr) { + // realpath() failed, fall back to original path + _profiler_name = info.dli_fname; + } _size = 0; } }