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: usleep() does not work on Linux 386 #21518

Closed
pvoicu opened this issue Aug 18, 2017 · 8 comments

Comments

Projects
None yet
6 participants
@pvoicu
Copy link
Contributor

commented Aug 18, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go1.8.3 linux/386

What operating system and processor architecture are you using (go env)?

GOARCH="386"
GOHOSTARCH="386"
GOHOSTOS="linux"
GOOS="linux"

What did you do?

It is internal function to the runtime package, so I cannot provide a test code to reproduce.
To reproduce, someone needs to compile any application for linux/386 and strace the second thread

What did you expect to see?

pselect6(0, NULL, NULL, NULL, {0, 20000}, 0) = 0 (Timeout)

What did you see instead?

I see pselect6(0, NULL, NULL, NULL, {0, 0}, 0) = 0 (Timeout)

runtime.usleep always sets the nanosecond parameter to 0. The fix is at line https://go.googlesource.com/go/+/master/src/runtime/sys_linux_386.s#103, it should be "MOVL AX, 4(SP)".

@ALTree

This comment has been minimized.

Copy link
Member

commented Aug 18, 2017

The CL that changed the linked function was not originally in go1.8, but it was cherrypicked here: https://go-review.googlesource.com/c/44002

It's also in go1.9rc2.

cc @aclements

@gopherbot

This comment has been minimized.

Copy link

commented Aug 18, 2017

Change https://golang.org/cl/56850 mentions this issue: runtime: fix usleep by correctly setting nanoseconds parameter for pselect6

@ALTree ALTree changed the title runtime.usleep() does not work on Linux 386 runtime: usleep() does not work on Linux 386 Aug 18, 2017

@ianlancetaylor ianlancetaylor added this to the Go1.9 milestone Aug 18, 2017

@gopherbot gopherbot closed this in 310be7b Aug 18, 2017

@aclements

This comment has been minimized.

Copy link
Member

commented Aug 18, 2017

Re-opening for cherry-pick to release branch.

@aclements aclements reopened this Aug 18, 2017

@gopherbot

This comment has been minimized.

Copy link

commented Aug 18, 2017

Change https://golang.org/cl/56891 mentions this issue: [release-branch.go1.9] runtime: fix usleep by correctly setting nanoseconds parameter for pselect6

@aclements

This comment has been minimized.

Copy link
Member

commented Aug 18, 2017

Cherry-pick to 1.8.4 is issue #21520.

Thanks for finding this @pvoicu!

gopherbot pushed a commit that referenced this issue Aug 18, 2017

[release-branch.go1.9] runtime: fix usleep by correctly setting nanos…
…econds parameter for pselect6

Fixes #21518

Change-Id: Idd67e3f0410d0ce991b34dcc0c8f15e0d5c529c9
Reviewed-on: https://go-review.googlesource.com/56891
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Petrica Voicu <pvoicu@paypal.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@ALTree

This comment has been minimized.

Copy link
Member

commented Aug 18, 2017

go1.9 cherrypick was merged: http://golang.org/cl/56891, so I'm closing this.

@ALTree ALTree closed this Aug 18, 2017

@tsuna

This comment has been minimized.

Copy link
Contributor

commented Aug 25, 2017

Thanks for fixing this bug, I was going crazy over runtime.sysmon taking up to 50% of the CPU cycles in my profiles as of late, and I thought it was something stupid we did in our own code that caused it. Today I realized the issue didn't exist in go1.8.2 and earlier, and didn't exist in go1.9 either, and traced it back to this issue.

@gopherbot

This comment has been minimized.

Copy link

commented Oct 14, 2017

Change https://golang.org/cl/70838 mentions this issue: [release-branch.go1.8] runtime: fix usleep by correctly setting nanoseconds parameter for pselect6

gopherbot pushed a commit that referenced this issue Oct 25, 2017

[release-branch.go1.8] runtime: fix usleep by correctly setting nanos…
…econds parameter for pselect6

Fixes #21518

Change-Id: Idd67e3f0410d0ce991b34dcc0c8f15e0d5c529c9
Reviewed-on: https://go-review.googlesource.com/56850
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-on: https://go-review.googlesource.com/70838
Run-TryBot: Russ Cox <rsc@golang.org>

@golang golang locked and limited conversation to collaborators Oct 14, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.