Skip to content
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

Potential issue: Stacktrace on Linux via addr2line won't work when process is looked up via PATH #72

Open
Schreischildkroete opened this issue Jan 30, 2019 · 2 comments

Comments

@Schreischildkroete
Copy link

Not sure if this can be considered a design issue or it's working as intended. However, when a stack trace is printed the line number an/or symbols can only be resolved via addr2line, when the process is NOT resolved via PATH. Otherwise the symbols are not correctly resolved, because internally the process is not found via addr2line.

If you need more information please feel free to ask.

@apolukhin
Copy link
Member

That's strange. addr2line based implementation uses dladdr for getting the symbol location. And that approach usually returns an absolute path via dli_fname.

What OS are you using? Is it Android?

@j-jr-richter
Copy link

Problem exists also on SLE-15 (SUSE Linux Enterprise).

Root cause is that for the main program dli_fname is not absolute andhence addr2line fails.

This small patch fixes it for me:

--- /usr/include/boost/stacktrace/detail/addr2line_impls.hpp    2018-05-25 20:30:40.000000000 +0200
+++ boost/stacktrace/detail/addr2line_impls.hpp 2020-07-22 10:43:25.242050818 +0200
@@ -114,7 +114,7 @@
     std::string res;
 
     boost::stacktrace::detail::location_from_symbol loc(addr);
-    if (!loc.empty()) {
+    if (!loc.empty() && strchr(loc.name(), '/') != NULL) { // for programs started through $PATH loc.name() is not absolute and addr2line will fail
         res = loc.name();
     } else {
         res.resize(16);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants