lmacken / pyrasite

Inject code into running Python processes

Home Page:http://pyrasite.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SIGSEGV from helloworld.py payload

posita opened this issue · comments

Running pyrasite out of a virtualenv inside a privileged Docker container:

$ /…/pyrasite/bin/pyrasite --verbose 809 helloworld.py
[New LWP 1605]
[New LWP 1790]
[New LWP 1791]
[New LWP 1792]
[New LWP 1803]
[New LWP 1805]
[New LWP 1807]
[New LWP 1809]
[New LWP 1810]
[New LWP 1811]
[New LWP 1813]
[New LWP 1814]
[New LWP 1818]
[New LWP 1819]
[New LWP 1821]
[New LWP 1826]
[New LWP 1829]
[New LWP 1830]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/…/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f9ee42bf6b3 in select () from /…/lib/x86_64-linux-gnu/libc.so.6

Thread 1 "debug_paster" received signal SIGSEGV, Segmentation fault.
0x00000000004d527c in ?? ()

Thread 9 "debug_paster" received signal SIG40, Real-time event 40.
[Switching to Thread 0x7f9eaffff700 (LWP 1809)]
0x00007f9ee42c65ac in epoll_pwait () from /…/lib/x86_64-linux-gnu/libc.so.6

The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on".
Evaluation of the expression containing the function
(PyGILState_Ensure) will be abandoned.
When the function is done executing, GDB will silently stop.
warning: Unable to restore previously selected frame.
The program received a signal in another thread while
making a function call from GDB.
Evaluation of the expression containing the function
(malloc) will be abandoned.
When the function is done executing, GDB will silently stop.
History has not yet reached $1.
Can't detach Thread 0x7f9ec61fd700 (LWP 1803): No such process

I can attach/detach with strace and gdb without issue inside the container, and thread apply all bt shows some meaningful information, but some symbols are missing. E.G.:

…
Thread 5 (Thread 0x7f6fd3fff700 (LWP 2367)):
#0  0x00007f6ff0aa36b3 in select () from /…/lib/x86_64-linux-gnu/libc.so.6
#1  0x00007f6ff0054d62 in floatsleep (secs=<optimized out>) at /…/python-2.7/Python-2.7.7-build/Python-2.7.7/Modules/timemodule.c:948
#2  time_sleep (self=<optimized out>, args=<optimized out>) at /…/python-2.7/Python-2.7.7-build/Python-2.7.7/Modules/timemodule.c:206
#3  0x00000000004af9a2 in ?? ()
#4  0x0000000000000000 in ?? ()

Thread 4 (Thread 0x7f6fd8834700 (LWP 2366)):
#0  0x00007f6ff0aa36b3 in select () from /…/lib/x86_64-linux-gnu/libc.so.6
#1  0x00007f6ff0054d62 in floatsleep (secs=<optimized out>) at /…/python-2.7/Python-2.7.7-build/Python-2.7.7/Modules/timemodule.c:948
#2  time_sleep (self=<optimized out>, args=<optimized out>) at /…/python-2.7/Python-2.7.7-build/Python-2.7.7/Modules/timemodule.c:206
#3  0x00000000004af9a2 in ?? ()
#4  0x0000000000000000 in ?? ()

Thread 3 (Thread 0x7f6fd9035700 (LWP 2365)):
#0  0x00007f6ff1490fd0 in sem_wait () from /…/lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00000000004b59a3 in ?? ()
#2  0x00007f6ff07773c0 in ?? ()
#3  0x00000000004583a0 in ?? ()
#4  0x0000000000000001 in ?? ()
#5  0x00005651affa1d90 in ?? ()
#6  0x00007f6fd92c2cb0 in ?? ()
#7  0x000000000046fa9d in ?? ()
#8  0x00007f6fd40232b0 in ?? ()
#9  0x00000001f050fdf8 in ?? ()
#10 0x00007f6ff07773c0 in ?? ()
#11 0x00007f6fd2b551b8 in ?? ()
#12 0x00007f6fd40232b0 in ?? ()
#13 0x00000000004af9a2 in ?? ()
#14 0x0000000000000000 in ?? ()
…

Would that be the issue? If not, any idea how to debug this?