Segfault in prctl.set_proctitle after import setproctitle
JelleZijlstra opened this issue · comments
Jelle Zijlstra commented
If you call prctl.set_proctitle
after you have imported setproctitle
(https://github.com/dvarrazzo/py-setproctitle), Python 3.6 segfaults.
$ python -c 'import setproctitle; import prctl; prctl.set_proctitle("hello")'
Segmentation fault
(title) jelle@devjelle:~$ pip freeze
python-prctl==1.7
setproctitle==1.1.10
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(title) jelle@devjelle:~$ python -V
Python 3.6.3
(title) jelle@devjelle:~$ lsb_release -d
Description: Ubuntu 16.04.4 LTS
The exact place where the crash happens varies; apparently some sort of memory corruption happens. In one gdb session, I found that __real_argv[0]
was NULL inside prctl_set_proctitle
. Just now I got this:
(gdb) bt
#0 update_refs (containers=<optimized out>) at Modules/gcmodule.c:346
#1 collect (generation=generation@entry=2, n_collected=n_collected@entry=0x7fffffffd5d0, n_uncollectable=n_uncollectable@entry=0x7fffffffd5d8, nofail=nofail@entry=0)
at Modules/gcmodule.c:955
#2 0x0000000000443ca7 in collect_with_callback (generation=2) at Modules/gcmodule.c:1128
#3 PyGC_Collect () at Modules/gcmodule.c:1592
#4 _PyGC_CollectIfEnabled () at Modules/gcmodule.c:1605
#5 0x0000000000424868 in Py_FinalizeEx () at Python/pylifecycle.c:603
#6 0x0000000000440ff4 in Py_Main (argc=argc@entry=3, argv=argv@entry=0x9b4010) at Modules/main.c:829
#7 0x000000000041e6e3 in main (argc=3, argv=<optimized out>) at ./Programs/python.c:69
Dennis Kaarsemaker commented
From a very quick glance at the code of the setproctitle module, it looks like it modifies argv. So all I can advice is not to try to use both modules in the same application.