Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deadlock by removing lock in frameNavigated #942

Merged
merged 2 commits into from
Jun 26, 2023

Conversation

ankur22
Copy link
Collaborator

@ankur22 ankur22 commented Jun 19, 2023

Description of changes

In certain navigations, the current frame may have child frames (e.g. iframes within a root frame). In these cases, the child frames need to be removed during a navigation. Before this change frameNavigated held onto framesMu lock for the whole duration of frameNavigated, but when it determined that the current root frame held child frames, it would call removeFramesRecursively. removeFramesRecursively, which is what removes the child frames, needs the same lock (framesMu) so it can amend the synchronised variable which holds all references to the frames on the current page.

It's also worth noting that this also prevents frameNavigated holding on to a lock when it calls ChildFrames, which requires another lock. It's generally unsafe to hold onto more than one lock at a time.

Closes: #941

Checklist

@ankur22 ankur22 requested review from inancgumus and ka3de June 19, 2023 17:14
@ankur22 ankur22 marked this pull request as draft June 19, 2023 17:14
Copy link
Collaborator

@ka3de ka3de left a comment

Choose a reason for hiding this comment

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

LGTM.

@ankur22 ankur22 marked this pull request as ready for review June 20, 2023 11:25
In certain navigations, the current frame may have child frames. In
these cases, the child frames need to be removed. frameNavigated holds
on to a framesMu lock for the whole duration of the frameNavigated.

removeFramesRecursively, which is what removes the child frames, needs
the same lock so that it can amend the synchronised variable.

It's also worth noting that this also prevent frameNavigated holding on
to a lock when it calls ChildFrames, which requires another lock. It's
generally unsafe to hold onto more than one lock at a time.
This test actually tests that we can navigate to a page with iframes,
click on a link, which navigates to another page with iframes. Once
at the second page it will end the test and we can assert. Without the
fix in the prior commit, this would panic on a deadlock.

NOTE: This only works when we have headless mode on.
@ankur22 ankur22 force-pushed the fix/941-frameNavigated-deadlock branch from 72a3d79 to c120d9e Compare June 26, 2023 11:01
@ankur22 ankur22 merged commit f3e86e7 into main Jun 26, 2023
@ankur22 ankur22 deleted the fix/941-frameNavigated-deadlock branch June 26, 2023 11:55
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.

Deadlock in FrameManager's frameNavigated when we navigate to certain websites
2 participants