This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jeethu
Recipients jeethu
Date 2018-01-17.15:35:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1516203304.77.0.467229070634.issue32584@psf.upfronthosting.co.za>
In-reply-to
Content
In one of patches I'm building, (yet another attempt at caching LOAD_GLOBALS)[1], I'm using the private APIs from PEP 523 to store an array with every code object. I'm calling _PyEval_RequestCodeExtraIndex with PyMem_Free for the freefunc argument. While running  the cpython testsuite, I found that test_embed case crashes with a segfault. The gdb backtrace[2] seems to indicate that PyInterpreterState::co_extra_freefuncs is uninitialized, while it should be a pointer to the PyMem_Free function. 

One way to work around this is to set the array as a member on the PyCodeObject struct and use it directly. And I've verified that it works. Am I using the PEP 523 private api correctly? Also, on Linux, this consistently crashes while on OSX, it occasionally doesn't crash which makes me wonder if it's some kind of a race condition involving Sub-interpreters. The attached gist[2] has steps for repro.

[1]: https://github.com/python/cpython/compare/master...jeethu:py3.7_load_global_cache
[2]: https://gist.github.com/jeethu/6d92185ca97dd692e7fadcd105e0ef70
History
Date User Action Args
2018-01-17 15:35:04jeethusetrecipients: + jeethu
2018-01-17 15:35:04jeethusetmessageid: <1516203304.77.0.467229070634.issue32584@psf.upfronthosting.co.za>
2018-01-17 15:35:04jeethulinkissue32584 messages
2018-01-17 15:35:04jeethucreate