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
syscall: Dup2 in fd_nacl.go calls files.Unlock more than once #24610
Comments
This indeed breaks on the Playground https://play.golang.org/p/zj2NzfP9iGQ |
Change https://golang.org/cl/103775 mentions this issue: |
actually I created same cl. but it does not get reviewed. |
@kybin Sorry about that. CLs without tracking issues tend to fall off our radar. |
@FiloSottile Never mind. I am happy with it. :) |
One small positive aspect of it is the fact that two independent CLs ended up being identical means it’s more likely the fix is optimal. :) |
This is an issue on tip, as of this issue creation time. It was originally spotted by @kybin in neelance@0f87113#r27472464 (but not reported here as far as I can tell).
Consider the implementation of
Dup2
insrc/syscall/fd_nacl.go
:go/src/syscall/fd_nacl.go
Lines 122 to 148 in 4468b0b
Lines 123 and 124 do
files.Lock()
anddefer files.Unlock()
.Lines 126 and 127 do
files.Unlock()
andreturn EBADF
.Lines 141 and 147 do
files.Unlock()
andreturn nil
.What did you expect to see?
Given that
Dup2
executesfiles.Lock()
once at the top, it should executefiles.Unlock()
exactly once before returning.What did you see instead?
files.Unlock()
is executed twice.Looking at the other methods, it feels like a copy/paste error. Some methods use
defer files.Unlock()
only, while other methods use individualfiles.Unlock()
calls beforereturn
without usingdefer files.Unlock()
.Dup2
does both.The text was updated successfully, but these errors were encountered: