Skip to content

Commit cbf0df7

Browse files
committed
Fix addr2line work when the process is looked up via PATH.
Fixes #72
1 parent 34e56c4 commit cbf0df7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

include/boost/stacktrace/detail/addr2line_impls.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <boost/stacktrace/detail/try_dec_convert.hpp>
1919
#include <boost/core/demangle.hpp>
2020
#include <cstdio>
21+
#include <cstring>
2122

2223
#include <sys/types.h>
2324
#include <sys/wait.h>
@@ -116,7 +117,9 @@ inline std::string addr2line(const char* flag, const void* addr) {
116117
std::string res;
117118

118119
boost::stacktrace::detail::location_from_symbol loc(addr);
119-
if (!loc.empty()) {
120+
// For programs started through $PATH loc.name() is not absolute and
121+
// addr2line will fail.
122+
if (!loc.empty() && std::strchr(loc.name(), '/') != nullptr) {
120123
res = loc.name();
121124
} else {
122125
res.resize(16);

0 commit comments

Comments
 (0)