#901774 Crash on SIGQUIT with plugin-python3

Package:
uwsgi-plugin-python3
Source:
uwsgi
Description:
WSGI plugin for uWSGI (Python 3)
Submitter:
wavexx
Date:
2025-02-03 13:54:01 UTC
Severity:
normal
#901774#5
Date:
2018-06-18 09:01:40 UTC
From:
To:
I'm using uwsgi to drive radicale using the python3 plugin.
My configuration is minimal, with a single master instance only running
radicale:

  /usr/bin/uwsgi --master --ini /etc/uwsgi/radicale.ini

the ini contains:

  [uwsgi]
  threads = 2
  manage-script-name = true
  plugin = python3
  mount = /url=/usr/share/radicale/radicale.wsgi
  logto = /var/log/radicale/uwsgi.log

In my .service file I'm using:

  [Service]
  KillSignal=SIGQUIT

Everything works. However, on SIGSTOP, uwsgi reliably crashes:

  #0  0x00007f5718229fe7 epoll_wait (libc.so.6)
  #0  0x00007f571a21c78c __lll_lock_wait (libpthread.so.0)
  #0  0x00007f77f4cf9a3d _PyType_Lookup (libpython3.6m.so.1.0)
  #1  0x0000564311427bc4 event_queue_wait (uwsgi-core)
  #1  0x00007f571a215cd5 __pthread_mutex_lock (libpthread.so.0)
  #1  0x00007f77f4cf9bae n/a (libpython3.6m.so.1.0)
  #10 0x00007f77f4ecb4fe PyEval_EvalCodeEx (libpython3.6m.so.1.0)
  #11 0x00007f77f4d6906b PyEval_EvalCode (libpython3.6m.so.1.0)
  #12 0x00007f77f4d742ad n/a (libpython3.6m.so.1.0)
  #13 0x00007f77f4dcdf01 PyCFunction_Call (libpython3.6m.so.1.0)
  #14 0x00007f77f4d705e0 _PyEval_EvalFrameDefault (libpython3.6m.so.1.0)
  #15 0x00007f77f4ecaa3f n/a (libpython3.6m.so.1.0)
  #16 0x00007f77f4ecb11e n/a (libpython3.6m.so.1.0)
  #17 0x00007f77f4d6a4f4 _PyEval_EvalFrameDefault (libpython3.6m.so.1.0)
  #18 0x00007f77f4ec98a3 n/a (libpython3.6m.so.1.0)
  #19 0x00007f77f4ecb2eb n/a (libpython3.6m.so.1.0)
  #2  0x00005643113e504e wsgi_req_accept (uwsgi-core)
  #2  0x00005643113e53a1 wsgi_req_accept (uwsgi-core)
  #2  0x00007f77f4d00a2b n/a (libpython3.6m.so.1.0)
  #20 0x00007f77f4d6a4f4 _PyEval_EvalFrameDefault (libpython3.6m.so.1.0)
  #21 0x00007f77f4ec98a3 n/a (libpython3.6m.so.1.0)
  #22 0x00007f77f4ecb2eb n/a (libpython3.6m.so.1.0)
  #23 0x00007f77f4d6a4f4 _PyEval_EvalFrameDefault (libpython3.6m.so.1.0)
  #24 0x00007f77f4ec98a3 n/a (libpython3.6m.so.1.0)
  #25 0x00007f77f4ecb2eb n/a (libpython3.6m.so.1.0)
  #26 0x00007f77f4d6a4f4 _PyEval_EvalFrameDefault (libpython3.6m.so.1.0)
  #27 0x00007f77f4ec98a3 n/a (libpython3.6m.so.1.0)
  #28 0x00007f77f4ecae43 _PyFunction_FastCallDict (libpython3.6m.so.1.0)
  #29 0x00007f77f4e76551 _PyObject_FastCallDict (libpython3.6m.so.1.0)
  #3  0x0000564311430336 simple_loop_run (uwsgi-core)
  #3  0x0000564311430336 simple_loop_run (uwsgi-core)
  #3  0x00007f77f4cfd455 n/a (libpython3.6m.so.1.0)
  #30 0x00007f77f4e76d46 _PyObject_CallMethodIdObjArgs (libpython3.6m.so.1.0)
  #31 0x00007f77f4ebda0c PyImport_ImportModuleLevelObject (libpython3.6m.so.1.0)
  #32 0x00007f77f4d70391 _PyEval_EvalFrameDefault (libpython3.6m.so.1.0)
  #33 0x00007f77f4ecaa3f n/a (libpython3.6m.so.1.0)
  #34 0x00007f77f4ecb4fe PyEval_EvalCodeEx (libpython3.6m.so.1.0)
  #35 0x00007f77f4d6906b PyEval_EvalCode (libpython3.6m.so.1.0)
  #36 0x00007f77f4d742ad n/a (libpython3.6m.so.1.0)
  #37 0x00007f77f4dcdf01 PyCFunction_Call (libpython3.6m.so.1.0)
  #38 0x00007f77f4d705e0 _PyEval_EvalFrameDefault (libpython3.6m.so.1.0)
  #39 0x00007f77f4ecaa3f n/a (libpython3.6m.so.1.0)
  #4  0x0000564311434d2c uwsgi_ignition (uwsgi-core)
  #4  0x00007f571a2135aa start_thread (libpthread.so.0)
  #4  0x00007f77f4e764a9 _PyObject_FastCallDict (libpython3.6m.so.1.0)
  #40 0x00007f77f4ecb11e n/a (libpython3.6m.so.1.0)
  #41 0x00007f77f4d6a4f4 _PyEval_EvalFrameDefault (libpython3.6m.so.1.0)
  #42 0x00007f77f4ec98a3 n/a (libpython3.6m.so.1.0)
  #43 0x00007f77f4ecb2eb n/a (libpython3.6m.so.1.0)
  #44 0x00007f77f4d6a4f4 _PyEval_EvalFrameDefault (libpython3.6m.so.1.0)
  #45 0x00007f77f4ec98a3 n/a (libpython3.6m.so.1.0)
  #46 0x00007f77f4ecb2eb n/a (libpython3.6m.so.1.0)
  #47 0x00007f77f4d6a4f4 _PyEval_EvalFrameDefault (libpython3.6m.so.1.0)
  #48 0x00007f77f4ec98a3 n/a (libpython3.6m.so.1.0)
  #49 0x00007f77f4ecb2eb n/a (libpython3.6m.so.1.0)
  #5  0x0000564311438304 uwsgi_worker_run (uwsgi-core)
  #5  0x00007f5718229cbf __clone (libc.so.6)
  #5  0x00007f77f4d731ea n/a (libpython3.6m.so.1.0)
  #50 0x00007f77f4d6a4f4 _PyEval_EvalFrameDefault (libpython3.6m.so.1.0)
  #51 0x00007f77f4ec98a3 n/a (libpython3.6m.so.1.0)
  #52 0x00007f77f4ecae43 _PyFunction_FastCallDict (libpython3.6m.so.1.0)
  #53 0x00007f77f4e76551 _PyObject_FastCallDict (libpython3.6m.so.1.0)
  #54 0x00007f77f4e76d46 _PyObject_CallMethodIdObjArgs (libpython3.6m.so.1.0)
  #55 0x00007f77f4ebda0c PyImport_ImportModuleLevelObject (libpython3.6m.so.1.0)
  #56 0x00007f77f4d72578 n/a (libpython3.6m.so.1.0)
  #57 0x00007f77f4dcded6 PyCFunction_Call (libpython3.6m.so.1.0)
  #58 0x00007f77f4e77178 PyObject_Call (libpython3.6m.so.1.0)
  #59 0x00007f77f4e77a68 PyObject_CallFunction (libpython3.6m.so.1.0)
  #6  0x00005643114388f2 uwsgi_run (uwsgi-core)
  #6  0x00007f77f4dcdd2a _PyCFunction_FastCallDict (libpython3.6m.so.1.0)
  #60 0x00007f77f4daef9b PyImport_Import (libpython3.6m.so.1.0)
  #61 0x00007f77f4daf19a PyImport_ImportModule (libpython3.6m.so.1.0)
  #62 0x00007f77f4e90acc _Py_InitializeEx_Private (libpython3.6m.so.1.0)
  #63 0x00007f77f551d8c9 uwsgi_python_init (python3_plugin.so)
  #7  0x00005643113e43ae main (uwsgi-core)
  #7  0x00007f77f4ecb20c n/a (libpython3.6m.so.1.0)
  #8  0x00007f5718154a87 __libc_start_main (libc.so.6)
  #8  0x00007f77f4d6a4f4 _PyEval_EvalFrameDefault (libpython3.6m.so.1.0)
  #9  0x00005643113e43da _start (uwsgi-core)
  #9  0x00007f77f4ecaa3f n/a (libpython3.6m.so.1.0)

I also tried to use --die-on-term instead of sending SIGQUIT, but the
behavior is the same.

#901774#10
Date:
2018-07-12 09:32:38 UTC
From:
To:
This is still true for 2.0.17. uwsgi-plugin-python3 cannot be gracefully
shutdown:

Stack trace of thread 31152:
#0  0x00007f01daecd822 n/a (libpython3.6m.so.1.0)
#1  0x00007f01daece83d PyGC_Collect (libpython3.6m.so.1.0)
#2  0x00007f01daef6f63 Py_FinalizeEx (libpython3.6m.so.1.0)
#3  0x000055d4178e9591 uwsgi_plugins_atexit (uwsgi-core)
#4  0x00007f01de0c98f1 n/a (libc.so.6)
#5  0x00007f01de0c99ea exit (libc.so.6)
#6  0x000055d41789dddf uwsgi_exit (uwsgi-core)
#7  0x000055d4178e80f5 end_me (uwsgi-core)
#8  0x00007f01dfb848e0 __restore_rt (libpthread.so.0)
#9  0x00007f01de189237 epoll_wait (libc.so.6)
#10 0x000055d4178de6e4 event_queue_wait (uwsgi-core)
#11 0x000055d41789b3fa wsgi_req_accept (uwsgi-core)
#12 0x000055d4178e6fe6 simple_loop_run (uwsgi-core)
#13 0x000055d4178e6df0 simple_loop (uwsgi-core)
#14 0x000055d4178ebb1c uwsgi_ignition (uwsgi-core)
#15 0x000055d4178ef114 uwsgi_worker_run (uwsgi-core)
#16 0x000055d4178ef6f4 uwsgi_run (uwsgi-core)
#17 0x000055d41789a6ae main (uwsgi-core)
#18 0x00007f01de0b3b17 __libc_start_main (libc.so.6)
#19 0x000055d41789a6da _start (uwsgi-core)

Stack trace of thread 31153:
#0  0x00007f01dfb8311c __lll_lock_wait (libpthread.so.0)
#1  0x00007f01dfb7c655 __pthread_mutex_lock (libpthread.so.0)
#2  0x000055d41789b6fc wsgi_req_accept (uwsgi-core)
#3  0x000055d4178e6fe6 simple_loop_run (uwsgi-core)
#4  0x00007f01dfb79f2a start_thread (libpthread.so.0)
#5  0x00007f01de188f0f __clone (libc.so.6)

#901774#15
Date:
2018-09-30 13:49:20 UTC
From:
To:
Hi wavexx,

Quoting wavexx (2018-07-12 11:32:38)
Could you please test if still an issue with uwsgi 2.0.17.1-6?

Kind regards,

 - Jonas

#901774#20
Date:
2018-09-30 16:15:34 UTC
From:
To:
I just tested and I don't get any crash during reload or shutdown.
Thanks a lot for digging into this!

#901774#25
Date:
2018-10-01 07:04:07 UTC
From:
To:
Ok, so I'm closing this bug then. Thanks!

Cheers,

Thomas Goirand (zigo)

#901774#30
Date:
2018-10-01 07:56:25 UTC
From:
To:
Quoting Yuri D'Elia (2018-09-30 18:15:34)

Thanks for confirming.  Closing accordingly.

 - Jonas

#901774#35
Date:
2018-10-22 17:15:47 UTC
From:
To:
I'm afraid to report that although since 2.0.17.1-6 it's rarer, I do
still get crashes during shutdown/reload/sigquit in uwsgid.

The stack trace is similar too, just less likely to happen:

#0  0x00007f1db9deabe0 _PyEval_FiniThreads (libpython3.6m.so.1.0)
#0  0x00007f2a3fdbc207 epoll_wait (libc.so.6)
#0  0x00007f2a4103611c __lll_lock_wait (libpthread.so.0)
#1  0x0000563a7c29afc4 event_queue_wait (uwsgi-core)
#1  0x00007f1db9dccf02 _Py_InitializeEx_Private (libpython3.6m.so.1.0)
#1  0x00007f2a4102f655 __pthread_mutex_lock (libpthread.so.0)
#10 0x0000563a7c2576ba _start (uwsgi-core)
#2  0x0000563a7c25838a wsgi_req_accept (uwsgi-core)
#2  0x0000563a7c2585ed wsgi_req_accept (uwsgi-core)
#2  0x00007f1dba130b3a uwsgi_python_init (python3_plugin.so)
#3  0x0000562bf95153d7 uwsgi_start (uwsgi-core)
#3  0x0000563a7c2a3a16 simple_loop_run (uwsgi-core)
#3  0x0000563a7c2a3a16 simple_loop_run (uwsgi-core)
#4  0x0000562bf9517610 uwsgi_setup (uwsgi-core)
#4  0x0000563a7c2a3800 simple_loop (uwsgi-core)
#4  0x00007f2a4102cf2a start_thread (libpthread.so.0)
#5  0x0000562bf94c3689 main (uwsgi-core)
#5  0x0000563a7c2a8485 uwsgi_ignition (uwsgi-core)
#5  0x00007f2a3fdbbedf __clone (libc.so.6)
#6  0x0000563a7c2ab9e4 uwsgi_worker_run (uwsgi-core)
#6  0x00007f1dbc98eb17 __libc_start_main (libc.so.6)
#7  0x0000562bf94c36ba _start (uwsgi-core)
#7  0x0000563a7c2abf64 uwsgi_run (uwsgi-core)
#8  0x0000563a7c25768e main (uwsgi-core)
#9  0x00007f2a3fce6b17 __libc_start_main (libc.so.6)