Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyStructSequence_NewType() not setting proper heap allocation flag? #64265

Closed
WolfIhlenfeldt mannequin opened this issue Dec 25, 2013 · 4 comments
Closed

PyStructSequence_NewType() not setting proper heap allocation flag? #64265

WolfIhlenfeldt mannequin opened this issue Dec 25, 2013 · 4 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@WolfIhlenfeldt
Copy link
Mannequin

WolfIhlenfeldt mannequin commented Dec 25, 2013

BPO 20066
Nosy @serhiy-storchaka, @corona10, @nanjekyejoannah

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2019-12-27.02:24:56.818>
created_at = <Date 2013-12-25.13:33:19.572>
labels = ['interpreter-core', 'type-crash']
title = 'PyStructSequence_NewType() not setting proper heap allocation flag?'
updated_at = <Date 2019-12-27.02:24:56.815>
user = 'https://bugs.python.org/WolfIhlenfeldt'

bugs.python.org fields:

activity = <Date 2019-12-27.02:24:56.815>
actor = 'corona10'
assignee = 'none'
closed = True
closed_date = <Date 2019-12-27.02:24:56.818>
closer = 'corona10'
components = ['Interpreter Core']
creation = <Date 2013-12-25.13:33:19.572>
creator = 'Wolf.Ihlenfeldt'
dependencies = []
files = []
hgrepos = []
issue_num = 20066
keywords = []
message_count = 4.0
messages = ['206923', '231331', '352501', '358896']
nosy_count = 4.0
nosy_names = ['serhiy.storchaka', 'Wolf.Ihlenfeldt', 'corona10', 'nanjekyejoannah']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'crash'
url = 'https://bugs.python.org/issue20066'
versions = ['Python 3.4', 'Python 3.5']

@WolfIhlenfeldt
Copy link
Mannequin Author

WolfIhlenfeldt mannequin commented Dec 25, 2013

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.

@WolfIhlenfeldt WolfIhlenfeldt mannequin added the type-crash A hard crash of the interpreter, possibly with a core dump label Dec 25, 2013
@serhiy-storchaka
Copy link
Member

See also bpo-15729.

@serhiy-storchaka serhiy-storchaka added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Nov 18, 2014
@nanjekyejoannah
Copy link
Member

As commented in bpo-15729, 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.

@corona10
Copy link
Member

Thanks @nanjekyejoannah for comment.

Yes, I found that the codes are updated.
see

type = (PyTypeObject *)PyType_FromSpecWithBases(&spec, bases);

I close this issue.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

3 participants