Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix borrow hazard creating intersection observer entries#45001

Merged
Gae24 merged 4 commits into
servo:mainfrom
SharanRP:44988
May 22, 2026
Merged

Fix borrow hazard creating intersection observer entries#45001
Gae24 merged 4 commits into
servo:mainfrom
SharanRP:44988

Conversation

@SharanRP
Copy link
Copy Markdown
Contributor

IntersectionObserverEntry::new() can trigger garbage collection but self.queued_entries.borrow_mut() was held during the call when GC traces the cell it tries to borrow again causing a panic , create the entry first then push it to avoid the borrow hazard

Fixes #44988

@SharanRP SharanRP requested a review from gterzian as a code owner May 19, 2026 06:12
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label May 19, 2026
Copy link
Copy Markdown
Contributor

@xiaochengh xiaochengh left a comment

Choose a reason for hiding this comment

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

The PR doesn't compile, can we fix it?

@SharanRP
Copy link
Copy Markdown
Contributor Author

yes looking into that

Finite::wrap(intersection_ratio),
target,
)
.as_traced();
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.

Move the as_traced() call to the push call instead to avoid this error.

target,
)
.as_traced(),
// > 2. Append it to observer's internal [[QueuedEntries]] slot.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: move this comment above self.queued_entries.borrow_mut().push(entry.as_traced());

@servo-highfive servo-highfive added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels May 19, 2026
Signed-off-by: SharanRP <[email protected]>
@servo-highfive servo-highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels May 19, 2026
@SharanRP
Copy link
Copy Markdown
Contributor Author

are the changes good ? @Gae24 @jdm @xiaochengh

Copy link
Copy Markdown
Contributor

@Gae24 Gae24 left a comment

Choose a reason for hiding this comment

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

Just to keep it consistent with how spec comments are written nowadays.

Comment thread components/script/dom/intersectionobserver.rs Outdated
Comment thread components/script/dom/intersectionobserver.rs Outdated
Comment thread components/script/dom/intersectionobserver.rs Outdated
@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label May 21, 2026
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label May 22, 2026
@Gae24 Gae24 added this pull request to the merge queue May 22, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label May 22, 2026
Merged via the queue into servo:main with commit 50d23d1 May 22, 2026
30 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Borrow hazard creating intersection observer entries

5 participants