Skip to content

Commit

Permalink
unix: fix finalizer fd close bug in TestOpenByHandleAt
Browse files Browse the repository at this point in the history
The raw fd is successively wrapped using os.NewFile, so dont defer close
the raw fd, but instead use (*os.File).Close.

Fixes golang/go#49403

Change-Id: I1f4b12536ff0abea6b1680a4ff932b7eefa57162
Reviewed-on: https://go-review.googlesource.com/c/sys/+/361995
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
  • Loading branch information
tklauser committed Nov 7, 2021
1 parent ebca88c commit e0b2ad0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions unix/syscall_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,10 +720,10 @@ func TestOpenByHandleAt(t *testing.T) {
if err != nil {
t.Fatalf("OpenByHandleAt: %v", err)
}
defer unix.Close(fd)

t.Logf("opened fd %v", fd)
f := os.NewFile(uintptr(fd), "")
defer f.Close()

slurp, err := ioutil.ReadAll(f)
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit e0b2ad0

Please sign in to comment.