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

Fix remaining memory bugs #443

Merged
merged 18 commits into from
Oct 10, 2024
Merged

Commits on Sep 24, 2024

  1. fix: Py_XDECREF requires the GIL to be held, but it's unavailable a…

    …fter Python finalization
    Xmader committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    7ea7a4c View commit details
    Browse the repository at this point in the history
  2. fix: accessing a non-existent property on a Python bytes in JS land…

    … should return `undefined` instead of throwing a Python error
    Xmader committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    3453696 View commit details
    Browse the repository at this point in the history
  3. fix: clean up SpiderMonkey when the PythonMonkey module gets destroyed

    We cannot use `Py_AtExit(cleanup);` because the GIL is unavailable after Python finalization, no more Python APIs can be called.
    Xmader committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    dd0aaed View commit details
    Browse the repository at this point in the history
  4. fix: to fix memory corruption, use PyUnicode_AsUTF8AndSize with the…

    … string size when possible
    Xmader committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    a0e3b05 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    667abc3 View commit details
    Browse the repository at this point in the history
  6. fix: to fix memory corruption, use PyUnicode_AsUTF8AndSize with the…

    … string size when possible
    Xmader committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    c804ca9 View commit details
    Browse the repository at this point in the history
  7. fix: PyEventLoop's destructor should not use any Python API, after …

    …the GIL is already handed over to another thread
    Xmader committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    7c74274 View commit details
    Browse the repository at this point in the history
  8. fix: PyUnicodeObject needs to be well-formed in a debug build of CP…

    …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
    Xmader committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    73957c0 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    5a13901 View commit details
    Browse the repository at this point in the history
  10. refactor: replace the use of our own roundtrip StrType::getValue me…

    …thod with the simpler `JS_EncodeStringToUTF8` SpiderMonkey API
    Xmader committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    8e365a7 View commit details
    Browse the repository at this point in the history
  11. fix: properly handle the reference count when doing list.concat()

    `PyList_SetItem` steals the reference, so we must increase the reference count by 1
    Xmader committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    0eeda35 View commit details
    Browse the repository at this point in the history
  12. perf: simply do a pythonic result = list[:] to get a copy of all it…

    …ems to the new list
    Xmader committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    c63b609 View commit details
    Browse the repository at this point in the history
  13. fix the reference count

    WIP: I don't know exactly why...
    Xmader committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    9474990 View commit details
    Browse the repository at this point in the history

Commits on Oct 1, 2024

  1. Merge branch 'Xmader/feat/python-3.13-support' into Xmader/fix/fix-me…

    …m-bugs-using-debug-build
    Xmader authored Oct 1, 2024
    Configuration menu
    Copy the full SHA
    a1f11b4 View commit details
    Browse the repository at this point in the history
  2. fix: reference count for array_fill

    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 <[email protected]>
    Xmader and zollqir committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    dda2916 View commit details
    Browse the repository at this point in the history
  3. set GLOBAL_CX = null in the final cleanup function since it's no lo…

    …nger usable/useful after the context is destroyed
    Xmader committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    5b9deec View commit details
    Browse the repository at this point in the history
  4. fix the reference count for dicts test_get_default_not_found in Pyt…

    …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.
    Xmader committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    a4762ae View commit details
    Browse the repository at this point in the history

Commits on Oct 10, 2024

  1. Configuration menu
    Copy the full SHA
    38309a3 View commit details
    Browse the repository at this point in the history