Skip to content

Instantly share code, notes, and snippets.

@jeethu
Created January 17, 2018 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeethu/6d92185ca97dd692e7fadcd105e0ef70 to your computer and use it in GitHub Desktop.
Save jeethu/6d92185ca97dd692e7fadcd105e0ef70 to your computer and use it in GitHub Desktop.
test_embed failure
jeethu@Odin:~/Projects/cpython/cpython$ /home/jeethu/Projects/cpython/cpython/Programs/_testembed repeated_init_and_subinterpreters
--- Pass 0 ---
interp 0 <0x55BF49FDF6A0>, thread state <0x55BF49FE00E0>: id(modules) = 139935889775752
interp 1 <0x55BF4A05A250>, thread state <0x55BF4A005B10>: id(modules) = 139935888903424
interp 2 <0x55BF4A05A250>, thread state <0x55BF4A005B10>: id(modules) = 139935870878984
interp 3 <0x55BF4A073B50>, thread state <0x55BF4A005B10>: id(modules) = 139935870878624
interp 0 <0x55BF49FDF6A0>, thread state <0x55BF49FE00E0>: id(modules) = 139935889775752
--- Pass 1 ---
interp 0 <0x55BF49FDF6A0>, thread state <0x55BF49FE00E0>: id(modules) = 139935889879128
interp 1 <0x55BF4A0C6FC0>, thread state <0x55BF4A005B10>: id(modules) = 139935871127024
Segmentation fault (core dumped)
jeethu@Odin:~/Projects/cpython/cpython$ gdb /home/jeethu/Projects/cpython/cpython/Programs/_testembed /tmp/cores/core._testembed.7757.Odin.1516157667
GNU gdb (Ubuntu 8.0.1-0ubuntu1) 8.0.1
Copyright (C) 2017 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 /home/jeethu/Projects/cpython/cpython/Programs/_testembed...done.
[New LWP 7757]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/home/jeethu/Projects/cpython/cpython/Programs/_testembed repeated_init_and_sub'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x000055bf492323bc in code_dealloc (co=co@entry=0x7f455cffef18) at Objects/codeobject.c:431
431 free_extra(co_extra->ce_extras[i]);
(gdb) backtrace
#0 0x000055bf492323bc in code_dealloc (co=co@entry=0x7f455cffef18) at Objects/codeobject.c:431
#1 0x000055bf49275d20 in _Py_Dealloc (op=0x7f455cffef18) at Objects/object.c:1904
#2 0x000055bf4924bd9b in func_dealloc (op=op@entry=0x7f455cf9d618) at Objects/funcobject.c:532
#3 0x000055bf49275d20 in _Py_Dealloc (op=0x7f455cf9d618) at Objects/object.c:1904
#4 0x000055bf4925f54b in free_keys_object (keys=keys@entry=0x7f455cfd1bc8) at Objects/dictobject.c:559
#5 0x000055bf49265e23 in PyDict_Clear (op=0x7f455cf96d78) at Objects/dictobject.c:1555
#6 0x000055bf4928e663 in type_clear (type=0x55bf4a007ee8) at Objects/typeobject.c:3532
#7 0x000055bf491a67a9 in delete_garbage (collectable=collectable@entry=0x7fff83729ad0, old=old@entry=0x55bf4964b690 <_PyRuntime+400>) at Modules/gcmodule.c:763
#8 0x000055bf491a72b3 in collect (generation=generation@entry=2, n_collected=n_collected@entry=0x0, n_uncollectable=n_uncollectable@entry=0x0, nofail=nofail@entry=1) at Modules/gcmodule.c:917
#9 0x000055bf491a7dd7 in _PyGC_CollectNoFail () at Modules/gcmodule.c:1600
#10 0x000055bf49178566 in PyImport_Cleanup () at Python/import.c:513
#11 0x000055bf491859f7 in Py_EndInterpreter (tstate=0x55bf4a005b10) at Python/pylifecycle.c:1436
#12 0x000055bf4915f6eb in test_repeated_init_and_subinterpreters () at ./Programs/_testembed.c:63
#13 0x000055bf4915f944 in main (argc=<optimized out>, argv=0x7fff83729d18) at ./Programs/_testembed.c:229
(gdb) p i
$1 = 0
(gdb) p free_extra
$2 = (freefunc) 0xcbcbcbcbcbcbcbcb
(gdb)
@jeethu
Copy link
Author

jeethu commented Jan 17, 2018

My working theory: co_extra_freefuncs is a field in the PyInterpreterState struct. If the underlying PyThreadState changes (i.e code objects traverse thread boundaries) and the code object ends up being freed, this results in a crash. https://bugs.python.org/issue30604 might be related to this issue.

Repro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment