Keep Python wrapper key buffers alive in WriteRange/ReadRange #43

Merged
andrew merged 1 commits from weaselbot/conflict-set:weaselbot/issue-42 into main 2026-06-23 01:17:46 +00:00
Member

Closes #42

Closes #42
andrew force-pushed weaselbot/issue-42 from 045bf9b5ef to 3e28538a15 2026-06-21 23:30:16 +00:00 Compare
andrew added 1 commit 2026-06-22 18:09:24 +00:00
Keep Python key buffers alive in WriteRange/ReadRange
CI / release (arm64, ubuntu-latest-arm64) (pull_request) Successful in 3m22s
CI / pre-commit (pull_request) Successful in 2m5s
CI / test (-DCMAKE_BUILD_TYPE=Debug, debug) (pull_request) Successful in 3m38s
CI / test (-DCMAKE_CXX_FLAGS=-DUSE_64_BIT=1, 64-bit-versions) (pull_request) Successful in 3m32s
CI / test (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc) (pull_request) Successful in 3m40s
CI / test (-DUSE_SIMD_FALLBACK=ON, simd-fallback) (pull_request) Successful in 3m28s
CI / release (amd64, ubuntu-latest-amd64) (pull_request) Successful in 4m53s
CI / coverage (pull_request) Successful in 3m40s
971deb477c
`write()` and `read()` created _Key objects from ephemeral ctypes arrays
backed by local bytearray objects. Once the helpers returned, those local
variables were freed, leaving the C library with dangling pointers when
addWrites()/check() later read the keys.

Store the backing bytearray on the returned WriteRange/ReadRange objects
as private `_begin_buf` / `_end_buf` attributes. Python keeps them alive
for the lifetime of the range object, so the C pointer is always valid.

Closes #42
andrew force-pushed weaselbot/issue-42 from 3e28538a15 to 971deb477c 2026-06-22 18:09:24 +00:00 Compare
andrew approved these changes 2026-06-23 01:17:34 +00:00
andrew left a comment
Owner

I don't think this can actually crash, but we'll merge it so weaselbot doesn't open it again

I don't think this can actually crash, but we'll merge it so weaselbot doesn't open it again
andrew merged commit 8f9f345c64 into main 2026-06-23 01:17:46 +00:00
andrew deleted branch weaselbot/issue-42 2026-06-23 01:17:47 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weaselab/conflict-set#43