pyo3/newsfragments
bors[bot] 32c335e072
Merge #3168 #3176
3168: Do not apply deferred ref count updates and prevent the GIL from being acquired inside of __traverse__ implementations. r=davidhewitt a=adamreichold

Closes #2301
Closes #3165


3176: Prevent dropping unsendable classes on other threads. r=davidhewitt a=adamreichold

Continuing the discussed from https://github.com/PyO3/pyo3/pull/3169#issuecomment-1556571504 and https://github.com/PyO3/pyo3/pull/3169#issuecomment-1556661723:

We already have checks in place to avoid borrowing these classes on other threads but it was still possible to send them to another thread and drop them there (while holding the GIL).
    
This change avoids running the `Drop` implementation in such a case even though Python will still free the underlying memory. This might leak resources owned by the object, but it avoids undefined behaviour due to access the unsendable type from another thread.
    
This does assume that the object was not unsafely integrated into an intrusive data structures which still point to the now freed memory. In that case, the only recourse would be to abort the process as freeing the memory is unavoidable when the tp_dealloc slot is called. (And moving it elsewhere into a new allocation would still break any existing pointers.)

Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
2023-05-25 18:18:46 +00:00
..
.gitignore use towncrier to generate CHANGELOG 2022-09-08 07:58:53 +01:00
2881.changed.md refactor PyAny::is_instance_of for performance 2023-05-18 22:25:27 +01:00
2980.added.md support `text_signature` on `#[new]` 2023-05-04 07:15:11 +01:00
2980.changed.md support `text_signature` on `#[new]` 2023-05-04 07:15:11 +01:00
2981.removed.md news entry for 0.17 deprecations removals 2023-05-09 09:39:23 +02:00
3004.changed.md feat: unwrap dyn Err when inner is simple PyErr 2023-05-09 07:17:10 +01:00
3016.added.md implement Decimal to rust_decimal conversions 2023-04-22 19:55:21 +02:00
3029.changed.md use dynamic trampoline for all getters and setters 2023-05-09 08:09:59 +01:00
3036.fixed.md fix const-ness of some FFI name & doc members 2023-03-10 16:02:52 +00:00
3050.changed.md Improve default values for str, numbers and bool in `text_signature` 2023-03-16 11:06:51 +08:00
3062.fixed.md stop panic on to_string, report using write_unraisable instead 2023-05-09 12:54:56 +02:00
3066.changed.md Improve default value for `None` in `text_signature` 2023-03-29 10:14:44 +08:00
3111.changed.md Rename sequence `.list()` and `.tuple()` to `.to_list()` and `.to_tuple()` 2023-04-18 20:52:49 +01:00
3120.added.md fix: change to from_item_all 2023-04-26 19:47:07 +08:00
3131.changed.md Extend lifetime of GIL token associated with PyRef(Mut). 2023-05-01 20:57:08 +02:00
3141.added.md Add BaseExceptionGroup for Python >= 3.11 2023-05-07 15:08:43 -05:00
3142.fixed.md Do not store return values in locals so that holders benefit from lifetime extension for temporaries. 2023-05-06 16:26:18 +02:00
3146.added.md Added a few lines to document the main difference between maturin and setuptools-rust as far as building manylinux-compliant wheels is concerned. 2023-05-09 14:54:30 +02:00
3152.packaging.md Fix patch version of our dependency on syn. 2023-05-10 22:31:15 +02:00
3157.added.md Add support for combining the `#[new]` and `#[classmethod]` method types. 2023-05-16 15:51:14 -07:00
3158.added.md Add PyClass::get and Py::get for GIL-independent access to frozen classes. 2023-05-18 08:57:55 +02:00
3161.added.md add `PyAny::is_exact_instance` and `PyAny::is_exact_instance_of` 2023-05-21 12:44:54 +02:00
3168.changed.md Do not apply deferred ref count updates and prevent the GIL from being acquired inside of implementations. 2023-05-25 20:01:35 +02:00
3168.fixed.md Do not apply deferred ref count updates and prevent the GIL from being acquired inside of implementations. 2023-05-25 20:01:35 +02:00
3176.fixed.md Prevent dropping unsendable classes on other threads. 2023-05-25 19:10:42 +02:00
3178.fixed.md Fix a span site of `_slf` for custom receivers. 2023-05-23 10:25:57 +09:00