MagicStack / MagicStack/uvloop

Segmentation fault

Open
#538 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Cython
Stars
11.9k
Forks
616
PR merge metrics
No merged PRs in 30d

Description

  • uvloop version:
    0.16.0
  • Python version:
    Python 3.7.10
  • Platform:
    Amazon Linux release 2 (Karoo)

It happens couple of times a day sometimes. And than does not happen for weeks:

Thread 2 "python3.7" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe71b3700 (LWP 31714)]
0x0000000000000000 in ?? ()
Missing separate debuginfos, use: debuginfo-install python3-3.7.10-1.amzn2.0.1.x86_64
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00007fffe97b2a5b in uv__read (stream=stream@entry=0x7fffe01bbe40) at src/unix/stream.c:1211
#2  0x00007fffe97b2f58 in uv__stream_io (loop=<optimized out>, w=0x7fffe01bbec8, events=1) at src/unix/stream.c:1316
#3  0x00007fffe97b9e75 in uv.io_poll () at src/unix/epoll.c:374
#4  0x00007fffe97ac684 in uv_run (loop=0x9982e0, mode=mode@entry=UV_RUN_DEFAULT) at src/unix/core.c:389
#5  0x00007fffe975e1f0 in __pyx_f_6uvloop_4loop_4Loop___run (__pyx_v_self=0xa19e70, __pyx_v_mode=UV_RUN_DEFAULT) at uvloop/loop.c:14642
#6  0x00007fffe976548d in __pyx_f_6uvloop_4loop_4Loop__run (__pyx_v_self=0xa19e70, __pyx_v_mode=UV_RUN_DEFAULT) at uvloop/loop.c:15030
#7  0x00007fffe96ebbc8 in __pyx_pf_6uvloop_4loop_4Loop_24run_forever (__pyx_v_self=0xa19e70) at uvloop/loop.c:27698
#8  __pyx_pw_6uvloop_4loop_4Loop_25run_forever (__pyx_v_self=0xa19e70, unused=<optimized out>) at uvloop/loop.c:27519
#9  0x00007ffff79d9db0 in _PyMethodDef_RawFastCallKeywords () from /lib64/libpython3.7m.so.1.0
#10 0x00007ffff79f37ed in _PyMethodDescr_FastCallKeywords () from /lib64/libpython3.7m.so.1.0
#11 0x00007ffff7a37cfb in _PyEval_EvalFrameDefault () from /lib64/libpython3.7m.so.1.0
#12 0x00007ffff79cce66 in _PyFunction_FastCallKeywords () from /lib64/libpython3.7m.so.1.0
#13 0x00007ffff7a3326f in _PyEval_EvalFrameDefault () from /lib64/libpython3.7m.so.1.0
#14 0x00007ffff79cce66 in _PyFunction_FastCallKeywords () from /lib64/libpython3.7m.so.1.0
#15 0x00007ffff7a3326f in _PyEval_EvalFrameDefault () from /lib64/libpython3.7m.so.1.0
#16 0x00007ffff7995757 in _PyFunction_FastCallDict () from /lib64/libpython3.7m.so.1.0
#17 0x00007ffff79a2711 in _PyObject_Call_Prepend () from /lib64/libpython3.7m.so.1.0
#18 0x00007ffff7995baa in PyObject_Call () from /lib64/libpython3.7m.so.1.0
#19 0x00007ffff7aa0b43 in t_bootstrap () from /lib64/libpython3.7m.so.1.0
#20 0x00007ffff7a4a147 in pythread_wrapper () from /lib64/libpython3.7m.so.1.0
#21 0x00007ffff741744b in start_thread () from /lib64/libpthread.so.0
#22 0x00007ffff6a0b40f in clone () from /lib64/libc.so.6

My app is using uvloop + aiohttp to continiously poll certain websites with high frequency. There are couple of threads which a sending tasks to a single thread where uvloop loop runs.

Both processes where this reproduces run at -17 and -20 niceness. There are some other processes with niceness around -10,-12 where it never reproduced. So maybe somehow related.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied GDB backtrace and inspect uvloop/loop.c around Loop.__run and Loop._run, then compare it with libuv's src/unix/stream.c and src/unix/epoll.c. Reproduce the intermittent SIGSEGV under the reported Python, uvloop, Amazon Linux, threading, and niceness conditions; done means the crash cause is identified and addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.