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

runtime: execLock might deadlock on darwin/ios #65587

Open
rsc opened this issue Feb 7, 2024 · 3 comments
Open

runtime: execLock might deadlock on darwin/ios #65587

rsc opened this issue Feb 7, 2024 · 3 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Feb 7, 2024

If you run

GOEXPERIMENT=staticlockranking go test strings

on a Mac, it fails badly, because the preemptM can be called while holding various locks that conflict with execLock.rlock, specifically this part:

// On Darwin, don't try to preempt threads during exec.
// Issue #41702.
if GOOS == "darwin" || GOOS == "ios" {
	execLock.rlock()
}

This is indicative of a real potential deadlock on macOS and iOS, though not one that seems to have been reported yet. So probably it's very rare if it can happen at all. Unclear how to fix that.

/cc @aclements

@rsc rsc added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 7, 2024
@rsc rsc added this to the Backlog milestone Feb 7, 2024
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Feb 7, 2024
@ianlancetaylor
Copy link
Contributor

The lock is only held while calling syscall.Exec, which is very rare. And the amount of time for a potential deadlock is very very short.

@ianlancetaylor
Copy link
Contributor

We could probably change the code so that instead of acquiring the lock in preemptM we just check whether we are currently in syscall.Exec. If we are, we could just skip the preemption signal. Most likely the process is going away anyhow. If it doesn't go away, we will presumably get another chance at preempting the thread.

@prattmic
Copy link
Member

prattmic commented Feb 8, 2024

I just modeled rwmutex more thoroughly in https://go.dev/cl/555055, which may be why this is showing up just now. Plus we don't have a darwin staticlockrank builder.

@mknyszek mknyszek assigned prattmic and unassigned prattmic Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin
Projects
Development

No branches or pull requests

5 participants