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

syscall: Segfault on Select on ARM64 and MIPS64 #24950

Closed
zx2c4 opened this issue Apr 19, 2018 · 3 comments
Closed

syscall: Segfault on Select on ARM64 and MIPS64 #24950

zx2c4 opened this issue Apr 19, 2018 · 3 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@zx2c4
Copy link
Contributor

zx2c4 commented Apr 19, 2018

The select syscall takes a timespec param. If it contains a time of zero, select returns immediately. If it contains a positive amount of time, select times out after that amount of time. If it is null, it never times out. Sometimes this latter behavior is desirable. It's well documented, mentioned in the man page, and used widely. However, https://go-review.googlesource.com/c/sys/+/70610 introduced a regression whereby Go will segfault if the timespec is nil, on ARM64 and MIPS64.

The current code for those platforms is:

func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
        ts := Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000}
        return pselect(nfd, r, w, e, &ts, nil)
}

The correct code should be:

func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
        if timeout != nil {
                ts := Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000}
                return pselect(nfd, r, w, e, &ts, nil)
        } else {
                return pselect(nfd, r, w, e, nil, nil)
        }
}

Currently I'm having to patch my local installation of Go to produce working executables for Android devices.

CC: @ianlancetaylor @tklauser

@ianlancetaylor
Copy link
Contributor

As I replied earlier on this CL, I believe this was fixed by https://golang.org/cl/97820.

@ianlancetaylor ianlancetaylor added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 19, 2018
@ianlancetaylor
Copy link
Contributor

Oh, sorry, you are talking about syscall, not x/sys/unix. First: use x/sys/unix. Second: in syscall this was fixed by https://golang.org/cl/97819, so the fix will be in 1.11. I don't think we need to backport this to 1.10 because: use x/sys/unix.

@zx2c4
Copy link
Contributor Author

zx2c4 commented Apr 19, 2018

Oh, great, okay.

zx2c4-bot pushed a commit to WireGuard/wireguard-android that referenced this issue Apr 27, 2018
@golang golang locked and limited conversation to collaborators Apr 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants