Skip to content

Improve registry storage assertions#9722

Open
andyleiserson wants to merge 3 commits into
gfx-rs:trunkfrom
andyleiserson:jj-push-opmk
Open

Improve registry storage assertions#9722
andyleiserson wants to merge 3 commits into
gfx-rs:trunkfrom
andyleiserson:jj-push-opmk

Conversation

@andyleiserson

@andyleiserson andyleiserson commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

In debugging a Firefox bug, I noticed that Storage::insert rejects attempts to insert the same resource ID twice, but silently drops (index, epoch1) if asked to insert (index, epoch2). This PR disallows that, and logs more information about expected / found IDs in several of the assertions.

Fixes #9685.

Testing
Claude wrote me some tests to sanity-check what the messages looked like, which I've included. They seem a little silly as permanent tests, on the other hand, I did add one for the "silently replace object in different epoch" case that was missed before.

Squash or Rebase? Squash

@ErichDonGubler ErichDonGubler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lezduit

Comment thread wgpu-core/src/storage.rs
self.kind, id
epoch,
storage_epoch,
"Cannot get {id:?}, found other resource {other:?}",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick(non-blocking): I wonder if it would be helpful to mention that it's the epoch that doesn't match?

This feedback applies in other places, too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: It'll be nice to be able to see the other resource's full ID in diagnostic output!

Comment thread wgpu-core/src/id.rs
#[cfg(test)]
impl Marker for () {}
impl Marker for () {
const TYPE: &'static str = "Untyped";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick(non-blocking): This is an edge-case that doesn't seem significant, but I wonder how confusing this would be with a macro-implemented Untyped type. 🙃

@ErichDonGubler ErichDonGubler self-assigned this Jun 23, 2026
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.

ID collisions on storage insertion should always panic

2 participants