Visitar URL original
Fix crashes found hunting the last open fuzzing record by youknowone · Pull Request #8524 · RustPython/RustPython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f24691e
specialize: check the member descriptor's type before caching its slo…
youknowone Aug 14, 2026
40e67e1
socket: reserve recv()'s buffer fallibly
youknowone Aug 14, 2026
40a839b
types: count the __call__ and __get__ slot dispatches as recursion
youknowone Aug 14, 2026
bb744d6
typevar: show a ParamSpecArgs origin by its repr
youknowone Aug 14, 2026
7e4b96e
Do not hold a lock across a call back into Python
youknowone Aug 14, 2026
6e47646
Validate memoryview.cast() arguments and export negative strides corr…
youknowone Aug 14, 2026
2432fd7
Charge native recursion to the stack, not to the frame limit
youknowone Aug 14, 2026
02a6193
Report a size that cannot be allocated instead of aborting on it
youknowone Aug 14, 2026
ff52fe0
marshal: answer allow_code where a code object is written or read
youknowone Aug 14, 2026
d7cf971
Do not lock an object while running code that can reach it
youknowone Aug 14, 2026
61b989b
Stop asserting a pbkdf2 message that depends on the width of a C long
youknowone Aug 14, 2026
c9449a6
Publish and read the same pointer for a thread's top frame
youknowone Aug 15, 2026
ee782e0
Decide stop-the-world parking under the thread registry lock
youknowone Aug 15, 2026
fab2b3b
Keep an atexit callback alive while it is being compared
youknowone Aug 15, 2026
e3dcd8e
Hold atexit entries in PyRc rather than Arc
youknowone Aug 15, 2026
773ae23
Do not hold a buffer's storage while waiting for a peer
youknowone Aug 15, 2026
125d5aa
Do not hold a buffer's storage while waiting to hand it over
youknowone Aug 15, 2026
62ed618
Check select()'s descriptor limit while the sequence is walked
youknowone Aug 15, 2026
c65fe42
Bound native recursion where the C stack cannot be measured
youknowone Aug 15, 2026
00b64c3
Report the failure to allocate pbkdf2's key and Take.readinto's scratch
youknowone Aug 15, 2026
7c40cb9
Read the frozen-code tuple length as a signed length
youknowone Aug 15, 2026
ce43008
Make the snippets from the fuzzer sweep assert what they check
youknowone Aug 15, 2026
3d69690
Ask for a marshal container's room instead of assuming it
youknowone Aug 15, 2026
366ef3e
Compare the blocking-buffer snippet against something
youknowone Aug 15, 2026
ab0d4ff
Refuse array.frombytes() a source whose items are not bytes
youknowone Aug 15, 2026
7fad3b0
Tell apart the ways marshal data can be bad
youknowone Aug 15, 2026
a7f7021
Hash the collector's tables by address rather than by SipHash
youknowone Aug 16, 2026
691d6ca
Keep the collection's candidates and their counts in one table
youknowone Aug 16, 2026
3139b95
gc: collect referents into one buffer instead of a vector per object
youknowone Aug 16, 2026
dce42a3
memoryview and struct: match the checks and errors of the reference
youknowone Aug 16, 2026
5a5ba17
io: decide the readinto path by file type, not by seekability
youknowone Aug 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Hold atexit entries in PyRc rather than Arc
PyObjectRef is Send and Sync only under the threading feature, so an Arc
over a callback entry trips clippy::arc_with_non_send_sync in builds
without it, such as the wasm package. PyRc is Arc there and Rc otherwise.

Assisted-by: Claude
  • Loading branch information
youknowone committed Aug 16, 2026
commit e3dcd8e9441ac0240d29d6de6db7c4db6cd39535
11 changes: 6 additions & 5 deletions crates/vm/src/stdlib/atexit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ pub(crate) use atexit::module_def;

#[pymodule]
mod atexit {
use crate::{AsObject, PyObjectRef, PyResult, VirtualMachine, function::FuncArgs};
use alloc::sync::Arc;
use crate::{
AsObject, PyObjectRef, PyResult, VirtualMachine, common::rc::PyRc, function::FuncArgs,
};

#[pyfunction]
fn register(func: PyObjectRef, args: FuncArgs, vm: &VirtualMachine) -> PyObjectRef {
// Callbacks go in LIFO order (insert at front)
vm.state
.atexit_funcs
.lock()
.insert(0, Arc::new((func.clone(), args)));
.insert(0, PyRc::new((func.clone(), args)));
func
}

Expand Down Expand Up @@ -49,7 +50,7 @@ mod atexit {
let mut funcs = vm.state.atexit_funcs.lock();
let mut j = (funcs.len() as isize - 1).min(i);
while j >= 0 {
if Arc::ptr_eq(funcs.get(j as usize).unwrap(), &entry) {
if PyRc::ptr_eq(funcs.get(j as usize).unwrap(), &entry) {
funcs.remove(j as usize);
i = j;
break;
Expand All @@ -73,7 +74,7 @@ mod atexit {
let funcs: Vec<_> = core::mem::take(&mut *vm.state.atexit_funcs.lock());
// Callbacks stored in LIFO order, iterate forward
for entry in funcs {
let (func, args) = Arc::try_unwrap(entry).unwrap_or_else(|e| (*e).clone());
let (func, args) = PyRc::try_unwrap(entry).unwrap_or_else(|e| (*e).clone());
if let Err(e) = func.call(args, vm) {
let exit = e.fast_isinstance(vm.ctx.exceptions.system_exit);
let msg = func
Expand Down
4 changes: 2 additions & 2 deletions crates/vm/src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use crate::{
stdlib,
warn::WarningsState,
};
use alloc::{borrow::Cow, collections::BTreeMap, sync::Arc};
use alloc::{borrow::Cow, collections::BTreeMap};
#[cfg(all(not(unix), feature = "threading"))]
use core::ptr::NonNull;
#[cfg(feature = "threading")]
Expand Down Expand Up @@ -762,7 +762,7 @@ pub struct PyGlobalState {
/// Registered `atexit` callbacks, newest first. Shared ownership so
/// `atexit.unregister` can keep the entry it is comparing alive while the
/// list is unlocked, and still recognize it afterwards by identity.
pub atexit_funcs: PyMutex<Vec<Arc<(PyObjectRef, FuncArgs)>>>,
pub atexit_funcs: PyMutex<Vec<PyRc<(PyObjectRef, FuncArgs)>>>,
pub codec_registry: CodecsRegistry,
pub finalizing: AtomicBool,
pub warnings: WarningsState,
Expand Down