classification
Title: PyStructSequence_NewType() not setting proper heap allocation flag?
Type: crash Stage: resolved
Components: Interpreter Core Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Wolf.Ihlenfeldt, corona10, nanjekyejoannah, serhiy.storchaka
Priority: normal Keywords:

Created on 2013-12-25 13:33 by Wolf.Ihlenfeldt, last changed 2019-12-27 02:24 by corona10. This issue is now closed.

Messages (4)
msg206923 - (view) Author: Wolf Ihlenfeldt (Wolf.Ihlenfeldt) Date: 2013-12-25 13:33
If I am not mistaken, I think that PyStructSequence_NewType() should set the Py_TPFLAGS_HEAPTYPE flag in tp->flags (which it currently does not). The original version initially works fine, but ultimately crashes at exit time in finalization with

Fatal Python error: type_traverse() called for non-heap type 'E_FILE'

#0  0x00007ffff12913d5 in raise () from /lib64/libc.so.6
#1  0x00007ffff1292858 in abort () from /lib64/libc.so.6
#2  0x00007ffff2360484 in Py_FatalError (msg=<optimized out>) at Python/pythonrun.c:2364
#3  0x00007ffff22e5354 in type_traverse (type=0x10b47a0, visit=0x7ffff2374350 <visit_decref>, arg=0x0)
    at Objects/typeobject.c:2892
#4  0x00007ffff2374bd1 in subtract_refs (containers=0x7ffff26466c0) at Modules/gcmodule.c:386
#5  collect (n_uncollectable=<synthetic pointer>, n_collected=<synthetic pointer>, generation=2)
    at Modules/gcmodule.c:891
#6  collect_with_callback (generation=2) at Modules/gcmodule.c:1048
#7  0x00007ffff2375436 in PyGC_Collect () at Modules/gcmodule.c:1476
#8  0x00007ffff235f698 in Py_Finalize () at Python/pythonrun.c:521
#9  0x00007ffff6e70b70 in CSpythonFinalize () at nmds_python.c:44652
#10 0x0000000000407399 in main ()

Setting the flag manually after creation lets the problem disappear.
msg231331 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-11-18 17:39
See also issue15729.
msg352501 - (view) Author: Joannah Nanjekye (nanjekyejoannah) * (Python committer) Date: 2019-09-16 00:57
As commented in issue15729, the Py_TPFLAGS_HEAPTYPE flag is now set in PyType_FromSpecWithBases() which is called by PyStructSequence_NewType(). I think this is no longer an issue.
msg358896 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2019-12-27 02:24
Thanks @nanjekyejoannah for comment.

Yes, I found that the codes are updated.
see https://github.com/python/cpython/blob/bd44a7ead9f7336d7bb45f186b2b6ca0300154f7/Objects/structseq.c#L488

I close this issue.
History
Date User Action Args
2019-12-27 02:24:56corona10setstatus: open -> closed

nosy: + corona10
messages: + msg358896

resolution: fixed
stage: needs patch -> resolved
2019-09-16 00:57:58nanjekyejoannahsetnosy: + nanjekyejoannah
messages: + msg352501
2014-11-18 17:39:53serhiy.storchakasetversions: + Python 3.4, Python 3.5, - Python 3.3
nosy: + serhiy.storchaka

messages: + msg231331

components: + Interpreter Core
stage: needs patch
2013-12-25 13:33:19Wolf.Ihlenfeldtcreate