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

net: Conn.Close() does not error on double close on wasm #45423

Open
johanbrandhorst opened this issue Apr 7, 2021 · 1 comment
Open

net: Conn.Close() does not error on double close on wasm #45423

johanbrandhorst opened this issue Apr 7, 2021 · 1 comment
Labels
arch-wasm WebAssembly issues NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@johanbrandhorst
Copy link
Member

Does this issue reproduce with the latest release?

Yes

What did you do?

Tried to write a test that checks whether a net.Conn is already closed by checking that calling Close returns an error and run it on wasm. See

if runtime.GOARCH == "wasm" {
t.Skip("conn.Close does not error as expected when called multiple times on WASM")
}
for the current workaround.

What did you expect to see?

An error suggesting that the connection has already been closed, as is consistent with all other architectures tested.

What did you see instead?

No error.

Discussion

I think the offending code is here:

go/src/net/net_fake.go

Lines 110 to 115 in 5d5f779

func (fd *netFD) Close() error {
fd.closedMu.Lock()
if fd.closed {
fd.closedMu.Unlock()
return nil
}

On unix platforms the behaviour is to return internal/poll.ErrNetClosing or internal/pool.ErrFileClosing:

func (fd *FD) Close() error {
if !fd.fdmu.increfAndClose() {
return errClosing(fd.isFile)
}

func errClosing(isFile bool) error {
if isFile {
return ErrFileClosing
}
return ErrNetClosing
}

@johanbrandhorst
Copy link
Member Author

@neelance

@seankhliao seankhliao added arch-wasm WebAssembly issues NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Apr 7, 2021
@seankhliao seankhliao added this to the Unplanned milestone Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly issues NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants