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

backtraces are not printed when running under Alpine Linux #1514

Open
jbehrends opened this issue Apr 18, 2017 · 4 comments
Open

backtraces are not printed when running under Alpine Linux #1514

jbehrends opened this issue Apr 18, 2017 · 4 comments

Comments

@jbehrends
Copy link

Alpine: 3.5.2
uWSGI 2.0.14

I'm experiencing a segfault issue with uwsgi running inside of Alpine, and no matter what I do I can't get ANY backtrace to be printed. I've tested this by installing the same uwsgi configuration into unbuntu and forcing a segfault (kill -SIGSEGV ) and I will get a backtrace everytime.

Poking around in the code, I think it's related to this line:

#if defined(__GLIBC__) || (defined(__APPLE__) && !defined(NO_EXECINFO)) || defined(UWSGI_HAS_EXECINFO)

I'm guessing the lack of GLIBC is the root cause. Not knowing a lot about c, would it be possible to update this to support musl libc as well for printing backtraces?

Thx

@xrmx
Copy link
Collaborator

xrmx commented Apr 19, 2017

It looks like musl doesn't provide execinfo.h which is a requirement for that code.

@jbehrends
Copy link
Author

Doing a little googling it appears that other projects have implemented "libunwind" as an alternative for backtrace functionality when running under Alpine/musl.

http://www.nongnu.org/libunwind/

@xrmx
Copy link
Collaborator

xrmx commented Apr 19, 2017

@jbehrends you are very welcome to open a PR or sponsor someone to do the work :)

jbakosi added a commit to quinoacomputing/quinoa that referenced this issue Mar 5, 2018
When exceptions are thrown or when a signal is caught, we want a
backtrace so we can diagnose problems.

For some reason I cannot debug further, execinfo's backtrace() function
call segfaults on alpine linux. This commit disables backtrace by
detecting the OS and turning backtrace off on alpine.

It appears that on alpine backtrace never worked for us, but we also
never tested it. ;-) Previously, it was disabled on RELEASE builds
(which we test) and now that I want to enable backtraces independent of
DEBUG vs RELEASE (or whatever), this breaks, so this commit puts in an
alpine-specific fix.

I'm not very happy with this solution. For example, detecing execinfo
instead would have been better, but alpine's quick'n'dirty
implementation of gnu's libexecinfo package does not provide a compiler
macro for detecting execinfo, so we disable backtrace on alpine.

References:

http://man7.org/linux/man-pages/man3/backtrace.3.html
https://pkgs.alpinelinux.org/package/edge/main/x86/libexecinfo-dev
https://www.freshports.org/devel/libexecinfo
https://www.gnu.org/software/libc/manual/html_node/Backtraces.html
unbit/uwsgi#1514 (may be related)
@caelus-dev
Copy link

caelus-dev commented Aug 14, 2023

Any solution to this problem? uWSGI raises segmentation error while using Apline but It's impossible to find the root of the problem without the backtrace.

I took a look at the aformentioned libunwind, but I couldn't find any description how that can help.

So do you have any exact solution to catch the backtrace or write it into a log file under Alpine?

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