-
Notifications
You must be signed in to change notification settings - Fork 40
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
Fix remaining memory bugs #443
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…fter Python finalization
… should return `undefined` instead of throwing a Python error
We cannot use `Py_AtExit(cleanup);` because the GIL is unavailable after Python finalization, no more Python APIs can be called.
… string size when possible
… string size when possible
…the GIL is already handed over to another thread
…ython Otherwise a `_PyObject_AssertFailed` error will be raised See: `_PyUnicode_CheckConsistency` https://github.com/python/cpython/blob/v3.11.3/Objects/unicodeobject.c#L594-L600, #L552-L553
…thod with the simpler `JS_EncodeStringToUTF8` SpiderMonkey API
`PyList_SetItem` steals the reference, so we must increase the reference count by 1
…ems to the new list
WIP: I don't know exactly why...
* thread #1, name = 'python', stop reason = signal SIGSEGV: address not mapped to object
* frame #0: 0x0000ffff97f6acf8 libpython3.11.so.1.0`PyObject_GC_Del [inlined] gc_list_remove(node=0x0000ffff9124d2b0) at gcmodule.c:269:5
frame #1: 0x0000ffff97f6acf8 libpython3.11.so.1.0`PyObject_GC_Del(op=0x0000ffff9124d2c0) at gcmodule.c:2350:9
frame #2: 0x0000ffff97f02d34 libpython3.11.so.1.0`maybe_freelist_clear(interp=0x0000ffff982706d0, fini=0) at tupleobject.c:1251:13
frame #3: 0x0000ffff9800cee0 libpython3.11.so.1.0`gc_collect_main [inlined] clear_freelists(interp=0x0000ffff982706d0) at gcmodule.c:1037:5
frame #4: 0x0000ffff9800ced8 libpython3.11.so.1.0`gc_collect_main(tstate=0x0000ffff9828aa50, generation=2, n_collected=0x0000000000000000, n_uncollectable=0x0000000000000000, nofail=1) at gcmodule.c:1313:9
frame #5: 0x0000ffff9800d5a4 libpython3.11.so.1.0`_PyGC_CollectNoFail(tstate=<unavailable>) at gcmodule.c:2110:9
frame #6: 0x0000ffff97ffd2a0 libpython3.11.so.1.0`Py_FinalizeEx at pylifecycle.c:1833:5
frame #7: 0x0000ffff9800b788 libpython3.11.so.1.0`Py_RunMain at main.c:682:9
frame #8: 0x0000ffff9800b468 libpython3.11.so.1.0`Py_BytesMain(argc=<unavailable>, argv=<unavailable>) at main.c:734:12
frame #9: 0x0000ffff97bb73fc libc.so.6`___lldb_unnamed_symbol2962 + 108
frame #10: 0x0000ffff97bb74cc libc.so.6`__libc_start_main + 152
frame #11: 0x0000aaaade3e08b0 python3.11`_start + 48
|
wesgarland
reviewed
Sep 24, 2024
zollqir
previously requested changes
Sep 24, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far, let me know when this is ready to merge and I can give it another pass
…m-bugs-using-debug-build
Since each call of `PyList_SetItem` steals a reference (even if its to the same object), we need multiple references to it for it to steal Co-authored-by: Caleb Aikens <caleb@distributive.network>
…nger usable/useful after the context is destroyed
…hon 3.11 Something is double-free-ed during the final finalization: in a debug build of Python, `./Include/object.h:602: _Py_NegativeRefcount: Assertion failed: object has negative ref count` In non-debug build of Python, it simply segfaults at the end during finalization.
wesgarland
approved these changes
Oct 10, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
wesgarland
temporarily deployed
to
github-pages
October 10, 2024 18:39
— with
GitHub Actions
Inactive
Xmader
had a problem deploying
to
github-pages
November 29, 2024 20:11
— with
GitHub Actions
Failure
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The CI sometimes fail on
main
even after we released the "stable" PythonMonkey v1.0.After all pytests are done, the program segfaults during the Python interpreter finalization.
Debugged using a debug build of Python