Skip to content

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

Merged
merged 1 commit into from
Aug 31, 2022
Merged

BUG: Support using libunwind for backtrack #22152

merged 1 commit into from
Aug 31, 2022

Conversation

RinCat
Copy link
Contributor

@RinCat RinCat commented Aug 18, 2022

Some system (e.g. musl) do not have "execinfo.h", and the backtracking
is provided by libunwind.

Fix: #22084

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
Copy link
Member

@seberg seberg Aug 20, 2022

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)

Copy link
Contributor Author

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.

Copy link
Member

@rgommers rgommers left a 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.

@rgommers rgommers merged commit 8b9b349 into numpy:main Aug 31, 2022
@rgommers rgommers added this to the 1.24.0 release milestone Aug 31, 2022
@rgommers rgommers added the 09 - Backport-Candidate PRs tagged should be backported label Aug 31, 2022
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Sep 6, 2022
@charris charris removed this from the 1.24.0 release milestone Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Second contribution
Development

Successfully merging this pull request may close these issues.

BUG: unable to build with musl, 'execinfo.h' file not found
4 participants