ianlancetaylor / libbacktrace

A C library that may be linked into a C/C++ program to produce symbolic backtraces
Other
944 stars 220 forks source link

Is it safe to load two executables? #116

Closed diehard2 closed 8 months ago

diehard2 commented 8 months ago

Hi, the interface looks like it would support this, but I noticed that libbacktrace is doing a significant amount of caching and I couldn't quite figure out everything you're doing there. The use case is a symbol server.

if I do something like the following, is it safe with the cache strategy?

auto exe_one = backtrace_create_state("./exe_one", 1, error_callback, nullptr); auto exe_two = backtrace_create_state("./exe_two", 1, error_callback, nullptr);

for (auto program_counter : backtrace_one) { if (backtrace_pcinfo(exe_one , program_counter, detail::full_callback, , 0, 0) != 0) { //Error } }

for (auto program_counter : backtrace_two) { if (backtrace_pcinfo(exe_two , program_counter, detail::full_callback, 0, 0) != 0) { //Error } }

ianlancetaylor commented 8 months ago

That should work fine, but the drawback is that there is no way to release all the cached information from the backtrace_state pointer. So you wouldn't want to do it this for an unlimited number of different executables.