script: Restrict scope of mutable borrow in IDBTransaction::ObjectStore.#40139
Merged
jdm merged 1 commit intoservo:mainfrom Oct 25, 2025
Merged
script: Restrict scope of mutable borrow in IDBTransaction::ObjectStore.#40139jdm merged 1 commit intoservo:mainfrom
jdm merged 1 commit intoservo:mainfrom
Conversation
mrobinson
approved these changes
Oct 24, 2025
yezhizhen
reviewed
Oct 25, 2025
Signed-off-by: Josh Matthews <[email protected]>
bf58995 to
25fdaee
Compare
yezhizhen
reviewed
Oct 25, 2025
| return Ok(DomRoot::from_ref(&*store)); | ||
| } | ||
|
|
||
| Ok(DomRoot::from_ref(&*store)) |
Member
There was a problem hiding this comment.
I don't know why this was never caught by Lint tho...
Only difference is that here we have a &mut Dom<IDBObjectStore>.
It is better to Ok(DomRoot::from_ref(store)) as well.
Member
There was a problem hiding this comment.
I guess the only reason is to downcast from &mut to &, although unnecessary when passing as arg.
yezhizhen
reviewed
Oct 25, 2025
| ); | ||
| self.store_handles | ||
| .borrow_mut() | ||
| .insert(name.to_string(), Dom::from_ref(&*store)); |
Member
There was a problem hiding this comment.
Now I am confused after #40155 (comment): what happens if store also get GCed before inserting?
Member
There was a problem hiding this comment.
storewon't be GCed because it is rootedIDBObjectStore::newcan trigger GC. GC here means tracing to check what can be collected, so my previous comment certainly make no sense as it is rooted.- The problem was the tracing would also try to mutably borrow the
RefCellresulting in hazards.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This avoids a borrow hazard when we create a new IDBObjectStore object and that triggers a GC.
Testing: Many IndexedDB tests no longer crash when using a debug mozjs build and full GC zeal. This configuration is not run in CI.
Fixes: #39946