Skip to content

Conversation

@BronzeDeer
Copy link
Contributor

@BronzeDeer BronzeDeer commented Apr 4, 2025

fixes #3970

As discussed in #3970 (comment) it might be better to put Target() and TargetGroup() (and some other public methods) under mutex protection as well for a more comprehensible fix


if s.debugger != nil {
s.debugger.LockTarget()
// Unlock immediatey, otherwise ProcessPid() will hang waiting for the mutex
Copy link
Member

Choose a reason for hiding this comment

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

This should be:

s.debugger.LockTarget()
cmdLine := s.debugger.Target().CmdLine
s.debugger.UnlockTarget()

and then cmdLine is used later instead s.debugger.Target().CmdLine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, you're absolutely right!

I'll update this commit.

I've also gone through the debugger's public methods and there are some more missing targetMutex.Lock(). Details are in this comment on the issue. I'd love a pointer as to whether it is preferrable for me to just add the missing mutex locks

@BronzeDeer BronzeDeer force-pushed the fix-dap-rr-race-condition branch from aa5666f to 0e41fac Compare April 4, 2025 15:14
@BronzeDeer
Copy link
Contributor Author

Updated with changes suggested in #3971 (comment)

Copy link
Member

@aarzilli aarzilli left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@derekparker derekparker left a comment

Choose a reason for hiding this comment

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

LGTM

@derekparker derekparker merged commit 84aae7f into go-delve:master Apr 7, 2025
2 checks passed
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.

[dap/launch] race condition causes nil pointer deref when using --backend=rr

3 participants