Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use Py_TRASHCAN_{BEGIN,END} in tp_dealloc functions - #9839

Merged
msullivan merged 3 commits into
masterfrom
trashcan
Dec 28, 2020
Merged

Use Py_TRASHCAN_{BEGIN,END} in tp_dealloc functions#9839
msullivan merged 3 commits into
masterfrom
trashcan

Conversation

@msullivan

@msullivan msullivan commented Dec 27, 2020

Copy link
Copy Markdown
Collaborator

See https://github.com/python/cpython/blob/master/Include/cpython/object.h#L456

Fixes mypyc/mypyc#789.

I didn't add a test because a test needs to create a lot of nodes.
Tested manually.

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this was a nasty bug. I assume that there's no easy way to fix this on Python 3.7 and earlier. Maybe we could implement something similar ourselves eventually?

Please add a follow-up issue to write a regression test to cover this case, once we have a way of adding expensive tests that only get run daily, for example.

emitter.emit_line('{}({} *self)'.format(dealloc_func_name, cl.struct_name(emitter.names)))
emitter.emit_line('{')
emitter.emit_line('PyObject_GC_UnTrack(self);')
emitter.emit_line('CPy_TRASHCAN_BEGIN(self, {})'.format(dealloc_func_name))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add short description of why we need to do this.

@msullivan

Copy link
Copy Markdown
Collaborator Author

This does work on on 3.7, but a new API got introduced in 3.8

@msullivan
msullivan merged commit fe8fac1 into master Dec 28, 2020
@msullivan
msullivan deleted the trashcan branch December 28, 2020 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

segfault during garbage collection (stackoverflow on deeply nested circular object?)

2 participants