#6267·pyo3

Unsoundness in buffer APIs

Author: Person-93Created Jul 31, 2026Updated Sep 12, 2026
LabelsUnsound

The slice accessors of PyBuffer return &core::cell::Cell (or &ReadOnlyCell) to guard memory which might be written by other threads, but Cell's guarantee is upheld by the fact that it's not Sync and no other threads can access that memory. https://github.com/rust-lang/rust/blob/8ab9fdff5a91b9f2b5ed57fb0275452d9a0d0280/library/core/src/cell.rs#L322-L328

It looks like the slice accessors may have relied on the GIL for soundness.