pyo3/tests
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
..
not_msrv pyo3-macros-backend: support macros inside doc attributes 2021-08-28 22:47:20 +01:00
ui Move locking the GIL and handling the resulting panics into a library function. 2023-05-25 20:01:35 +02:00
common.rs Factor out UnraisableCapture helper type and use it to check that dropping unsendable elsewhere calls into sys.unraisablehook 2023-05-25 20:17:55 +02:00
test_anyhow.rs clippy: enable some more lints 2022-03-03 07:23:28 +00:00
test_append_to_inittab.rs Add macro append_to_inittab 2022-05-24 07:42:15 +01:00
test_arithmetics.rs Use Python:;with_gil in tests 2022-07-19 19:34:23 +02:00
test_buffer.rs Add more lints 2022-03-23 08:07:28 +01:00
test_buffer_protocol.rs Factor out UnraisableCapture helper type and use it to check that dropping unsendable elsewhere calls into sys.unraisablehook 2023-05-25 20:17:55 +02:00
test_bytes.rs Use Python:;with_gil in tests 2022-07-19 19:34:23 +02:00
test_class_attributes.rs Reduce visibility of CaptureStdErr type to avoid warnings on older toolchains. 2023-02-18 17:11:40 +01:00
test_class_basics.rs Factor out UnraisableCapture helper type and use it to check that dropping unsendable elsewhere calls into sys.unraisablehook 2023-05-25 20:17:55 +02:00
test_class_conversion.rs Use Python:;with_gil in tests 2022-07-19 19:34:23 +02:00
test_class_new.rs Fix being able to call arg-less #[new] with any args from Python 2022-11-20 08:25:19 +01:00
test_compile_error.rs Move traverse-bare-self UI test to version-gated section as its error output is not stable between MSRV and current stable. 2023-05-25 20:02:51 +02:00
test_datetime.rs refactor PyAny::is_instance_of for performance 2023-05-18 22:25:27 +01:00
test_default_impls.rs fix some typos 2022-04-24 22:06:32 +08:00
test_dict_iter.rs Use Python:;with_gil in tests 2022-07-19 19:34:23 +02:00
test_enum.rs Some improvements to __richcmp__ on enums 2022-09-16 15:30:56 +01:00
test_exceptions.rs Factor out UnraisableCapture helper type and use it to check that dropping unsendable elsewhere calls into sys.unraisablehook 2023-05-25 20:17:55 +02:00
test_field_cfg.rs Add test 2022-12-28 23:11:39 +01:00
test_frompyobject.rs Fix new clippy warnings in Rust 1.63.0 2022-08-12 11:50:23 +08:00
test_gc.rs Move locking the GIL and handling the resulting panics into a library function. 2023-05-25 20:01:35 +02:00
test_getter_setter.rs feat: add #[pyo3(get, set)] for Cell 2023-03-09 23:09:30 +00:00
test_inheritance.rs refactor PyAny::is_instance_of for performance 2023-05-18 22:25:27 +01:00
test_macros.rs add #[pyo3(signature = (...))] attribute (#2702) 2022-10-25 07:23:21 +01:00
test_mapping.rs Update PyTryFrom for PyMapping and PySequence to more accurately check types (#2477) 2022-08-10 21:03:18 +01:00
test_methods.rs Fix a span site of _slf for custom receivers. 2023-05-23 10:25:57 +09:00
test_module.rs add #[pyo3(signature = (...))] attribute (#2702) 2022-10-25 07:23:21 +01:00
test_multiple_pymethods.rs Use Python::get_type() instead of PyTypeInfo::type_object() 2022-11-20 15:16:18 +01:00
test_not_msrv.rs dev: remove self dev dependency 2021-12-08 07:48:58 +00:00
test_pep_587.rs add regression test for PEP 587 2022-05-15 16:08:21 +01:00
test_proto_methods.rs Py/PyAny: deprecate cast_as() in favor of downcast() 2022-11-18 07:00:40 +01:00
test_pyfunction.rs Add test case requiring the maximum lifetime of the holder references. 2023-05-06 12:42:05 +02:00
test_pyself.rs Use Python:;with_gil in tests 2022-07-19 19:34:23 +02:00
test_sequence.rs remove Python::acquire_gil 2023-05-09 09:39:23 +02:00
test_serde.rs Py/PyAny: remove PartialEq impl and add is() (#2183) 2022-02-25 19:39:45 +00:00
test_static_slots.rs Test static __getitem__ as well as __len__ 2023-03-18 13:56:51 +00:00
test_string.rs Use Python:;with_gil in tests 2022-07-19 19:34:23 +02:00
test_super.rs Add super object (#2486) 2022-07-03 19:21:15 +01:00
test_text_signature.rs Do not assert class text signature using the limited API before version 3.10 as we do not support it. 2023-05-04 18:28:43 +02:00
test_unsendable_dict.rs Use Python:;with_gil in tests 2022-07-19 19:34:23 +02:00
test_variable_arguments.rs add #[pyo3(signature = (...))] attribute (#2702) 2022-10-25 07:23:21 +01:00
test_variable_arguments_deprecated.rs add #[pyo3(signature = (...))] attribute (#2702) 2022-10-25 07:23:21 +01:00
test_various.rs Use Python:;with_gil in tests 2022-07-19 19:34:23 +02:00
test_wrap_pyfunction_deduction.rs Add more lints 2022-03-23 08:07:28 +01:00