-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
BUG: Support using libunwind for backtrack #22152
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
Conversation
Some system (e.g. musl) do not have "execinfo.h", and the backtracking is provided by libunwind. Fix: numpy#22084
#include <execinfo.h> | ||
#elif defined HAVE_LIBUNWIND_H | ||
#include <libunwind.h> | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this makes sense to me now, although if neither is found, I guess the whole thing should be disabled (which is on line 61)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, HAVE_BACKTRACE
should disabled those include if backtrack()
not found. Unless new backtracking library showed up, which should throw an error to notice devs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test for backtrace
we are using is in numpy/core/feature_detection_misc.h
:
#include <stddef.h>
int backtrace(void **, int);
int madvise(void *, size_t, int);
It's not entirely clear to me how backtrace
ends up usable when including stddef.h
, but it does seem to work. And libunwind
indeed has backtrace
, as an alias to its own unw_backtrace
: https://github.com/dropbox/libunwind/blob/16bf4e5e498c7fc528256843a4a724edc2753ffd/src/mi/backtrace.c#L58-L79
So this PR looks like an improvement. It solves a build issue, so let's just merge it as is. If we find another case of backtrace
existing but not being provided by either execinfo.h
or libunwind.h
, let's deal with a bigger reshuffle of this code at that point.
Some system (e.g. musl) do not have "execinfo.h", and the backtracking
is provided by libunwind.
Fix: #22084