Skip to content

Report a poisoned lock where it was taken, and stop converting PoisonError publicly - #1641

Merged
cberner merged 1 commit into
masterfrom
claude/sweet-hypatia-m4vct7-lock-poisoned
Nov 9, 2026
Merged

cberner merged 1 commit into
masterfrom
claude/sweet-hypatia-m4vct7-lock-poisoned

Conversation

@cberner

@cberner cberner commented Nov 9, 2026

Copy link
Copy Markdown
Owner

StorageError and Error implemented From<PoisonError<T>> publicly, so that redb's own code could write self.state.lock()?. That has two problems:

  • The location is always wrong. LockPoisoned records Location::caller(), but from wasn't #[track_caller], so every poisoned lock was reported at the same line inside error.rs.
  • It blames redb for other code's locks. Because the impls are public, a user function returning redb::Error can ? its own poisoned Mutex into Error::LockPoisoned, whose message says "Poisoned internal lock".

Changes:

  • The 8 lock sites (page_manager, transaction_tracker, base, table_tree) now use a crate-private LockResultExt::or_poisoned(). It's #[track_caller], so LockPoisoned points at the line that took the lock.
  • Under experimental-api-5, the public From<PoisonError<T>> impls are removed.
  • Without the feature, they stay, now marked #[track_caller], so 4.x callers also get the right location.
  • Test: lock_poisoned_reports_the_lock_site poisons a mutex and checks the reported file and line. I confirmed it fails without #[track_caller]: it reports the helper's own line.
  • CHANGELOG: one line under the 5.0 breaking changes.

Checked:

  • cargo fmt.
  • clippy --all --all-targets, with and without --all-features.
  • clippy for thumbv7em (no_std).
  • cargo test --all-features, and cargo test with default features.
  • The no_std regression crate.

Generated by Claude Code

…Error publicly

StorageError and Error converted a PoisonError into LockPoisoned through
public From impls, which recorded Location::caller() without
#[track_caller], so every poisoned lock was reported at the same line
inside error.rs. Being public, they also let a caller convert its own
poisoned lock into a redb error that blames redb.

redb's lock sites now convert through a crate-private helper that
records where the lock was taken. Under experimental-api-5 the public
impls are removed; without it they remain, now with #[track_caller].

Assisted-by: Claude Code
Claude-Session: https://claude.ai/code/session_01ALhxet6NP69dCfAUv8TAhR
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T01:15:05.950278Z 1c5ee4d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cberner
cberner merged commit 0d0b755 into master Nov 9, 2026
5 checks passed
@cberner
cberner deleted the claude/sweet-hypatia-m4vct7-lock-poisoned branch November 9, 2026 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant