Uwsgi: python3.7, python plugin, auto reloader, namespace packages => segmentation fault

Created on 23 Jul 2018  路  2Comments  路  Source: unbit/uwsgi

Here's a minimal reproduction and a backtrace from a -g debug build

below aspy.yaml is a namespace package

The difference that causes uwsgi to segfault:

$ python3.6
>>> import aspy
>>> aspy.__file__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'aspy' has no attribute '__file__'
$ python3.7
>>> import aspy
>>> aspy.__file__
>>>

reproduction

FROM ubuntu:bionic

RUN : \
    && apt-get update \
    && apt-get install -y software-properties-common \
    && add-apt-repository -y ppa:deadsnakes \
    && apt-get update \
    && apt-get install -y python3.7-dbg python3.7-dev python3-pip \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /code
RUN CFLAGS=-g python3.7-dbg -mpip install uwsgi==2.0.17.1
# comment me out to fix
RUN python3.7-dbg -mpip install aspy.yaml==1.1.1 pyyaml==3.13

COPY wsgi.py .

CMD uwsgi --http 0.0.0.0:5000 --wsgi-file wsgi.py --py-autoreload=1
def application(environ, start_response):
    start_response('200 OK', [('Content-type', 'text/plain')])
    return [b'Hello world\n']
# gdb $(which uwsgi) core.uwsgi.22 
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/local/bin/uwsgi...done.
[New LWP 22]
[New LWP 24]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
tCore was generated by `uwsgi --http 0.0.0.0:5000 --wsgi-file wsgi.py --py-autoreload=1'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f13d2b3ebb7 in epoll_wait (epfd=4, 
    events=events@entry=0x7fff8c3c607c, maxevents=maxevents@entry=1, 
    timeout=-1) at ../sysdeps/unix/sysv/linux/epoll_wait.c:30
30  ../sysdeps/unix/sysv/linux/epoll_wait.c: No such file or directory.
[Current thread is 1 (Thread 0x7f13d4176740 (LWP 22))]
(gdb) t 2
[Switching to thread 2 (Thread 0x7f13d14f1700 (LWP 24))]
#0  0x00007f13d17074a4 in OPENSSL_LH_free ()
   from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
(gdb) bt
#0  0x00007f13d17074a4 in OPENSSL_LH_free ()
   from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
#1  0x00007f13d16ea998 in err_free_strings_int ()
   from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
#2  0x00007f13d1705ac5 in OPENSSL_cleanup ()
   from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
#3  0x00007f13d2a60041 in __run_exit_handlers (status=1, 
    listp=0x7f13d2e08718 <__exit_funcs>, 
    run_list_atexit=run_list_atexit@entry=true, 
    run_dtors=run_dtors@entry=true) at exit.c:108
#4  0x00007f13d2a6013a in __GI_exit (status=<optimized out>) at exit.c:139
#5  0x000055bbf2d7de6f in uwsgi_exit (status=<optimized out>)
    at core/utils.c:4443
#6  0x000055bbf2dc87d3 in uwsgi_segfault (signum=11) at core/uwsgi.c:1872
#7  <signal handler called>
#8  PyBytes_AsString (op=op@entry=0x0) at ../Objects/bytesobject.c:1285
#9  0x000055bbf2dd6366 in uwsgi_python_autoreloader_thread (
    foobar=<optimized out>) at plugins/python/python_plugin.c:1486
#10 0x00007f13d3d426db in start_thread (arg=0x7f13d14f1700)
    at pthread_create.c:463
#11 0x00007f13d2b3e88f in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

The line it points at is here

Most helpful comment

seems this is already fixed thanks to https://github.com/unbit/uwsgi/commit/d6d3ecdd7c6a76a739be59a5f8de024a2daeb2db -- looking forward to a release!

1825

All 2 comments

seems this is already fixed thanks to https://github.com/unbit/uwsgi/commit/d6d3ecdd7c6a76a739be59a5f8de024a2daeb2db -- looking forward to a release!

1825

any plans when this issue will be included in a release ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xrmx picture xrmx  路  5Comments

GaretJax picture GaretJax  路  7Comments

ercwyne picture ercwyne  路  4Comments

bhaskarsai picture bhaskarsai  路  4Comments

alanhamlett picture alanhamlett  路  6Comments