PyO3 / PyO3/pyo3

Unsoundness in buffer APIs

Open
#6,267 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Unsound
Dominant language
Rust
Stars
16.2k
Forks
1k
Avg merge
2d 6h
Merged PRs (30d)
66

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the PyBuffer slice accessors and the linked Rust Cell documentation in library/core/src/cell.rs. Trace whether those accessors depend on the GIL for thread-safety; done means the soundness status and required API change are clearly resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.