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: failure to getPageSize on netbsd-386 #22914

Closed
bradfitz opened this issue Nov 29, 2017 · 7 comments
Closed

runtime: failure to getPageSize on netbsd-386 #22914

bradfitz opened this issue Nov 29, 2017 · 7 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-NetBSD
Milestone

Comments

@bradfitz
Copy link
Contributor

bradfitz commented Nov 29, 2017

I'm trying to revive the NetBSD port.

We have passing NetBSD 8-BETA builders for amd64 now.

The NetBSD i386 kernel fails to get networking on GCE, but the 64-bit NetBSD kernel can run 32-bit binaries (like FreeBSD and unlike OpenBSD), and that's how we used to run the netbsd-386 builder, so I'm trying that again.

But 32-bit binaries fail to get the page size on a 64-bit kernel:

Running /tmp/workdir/go/src/all.bash with args ["/tmp/workdir/go/src/all.bash"] and env ["PWD=/" "HOME=/" "PATH=/usr/pkg/bin:/usr/pkg/sbin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/pkg/sbin:/usr/pkg/bin:/usr/X11R7/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin" "_rc_original_stdout_fd=7" "GOROOT_BOOTSTRAP=/tmp/workdir/go1.4" "_rc_original_stderr_fd=8" "RC_PID=  10" "_rc_pid=2" "_rc_postprocessor_fd=9" "WORKDIR=/tmp/workdir" "GO_BUILDER_NAME=netbsd-386-8branch" "GOARCH=386" "GOHOSTARCH=386"] in dir /tmp/workdir/go/src
Building Go toolchain1 using /tmp/workdir/go1.4.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
fatal error: failed to get system page size
runtime: panic before malloc heap initialized

runtime stack:     
runtime.throw(0x82bf412, 0x1e)
        /tmp/workdir/go/src/runtime/panic.go:616 +0x65 fp=0xffffe718 sp=0xffffe70c pc=0x806e025
runtime.mallocinit()        
        /tmp/workdir/go/src/runtime/malloc.go:232 +0x3ba fp=0xffffe758 sp=0xffffe718 pc=0x8055c6a
runtime.schedinit()         
        /tmp/workdir/go/src/runtime/proc.go:485 +0x3c fp=0xffffe780 sp=0xffffe758 pc=0x807029c
runtime.rt0_go(0xffffe814, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /tmp/workdir/go/src/runtime/asm_386.s:297 +0x224 fp=0xffffe784 sp=0xffffe780 pc=0x8091ef4
go tool dist: FAILED: /tmp/workdir/go/pkg/tool/netbsd_386/go_bootstrap install -gcflags=all= -ldflags=all= -i cmd/asm cmd/cgo cmd/compile cmd/link: exit status 2

Obviously not correct, but falling back to 4KB instead of returning 0 on sysctl failure seems to make it get further:

bradfitz@gdev:~/go/src$ git di
diff --git a/src/runtime/os_netbsd.go b/src/runtime/os_netbsd.go
index 39e91ee..a35bd1c 100644
--- a/src/runtime/os_netbsd.go
+++ b/src/runtime/os_netbsd.go
@@ -106,6 +106,9 @@ func getPageSize() uintptr {
        if ret >= 0 {
                return uintptr(out)
        }       
+       if GOOS == "netbsd" {
+               return 4 << 10  
+       }               
        return 0        
 }              

Now instead of crashing, make.bash seems to hang forever, consuming CPU forever in /tmp/workdir/go/pkg/tool/netbsd_386/go_bootstrap install.

Ideas welcome.

/cc @bsiegert @aclements @krytarowski @ianlancetaylor

@bradfitz bradfitz added NeedsFix The path to resolution is known, but the work has not been done. OS-NetBSD labels Nov 29, 2017
@bradfitz bradfitz added this to the Go1.10 milestone Nov 29, 2017
@bradfitz
Copy link
Contributor Author

If we don't get netbsd-386 working again, we'll just document it in the release notes. That is #22911. At least having any NetBSD working again would be an improvement. (Go 1.9 didn't run on NetBSD at all.)

@bradfitz
Copy link
Contributor Author

Debugging this would be easier once ssh is enabled for NetBSD. That is #22872.

@krytarowski
Copy link
Contributor

Panic... this looks badly. Trying to reproduce locally.

@gopherbot
Copy link

Change https://golang.org/cl/80435 mentions this issue: all: start to revive netbsd-386 support

@coypoop
Copy link
Contributor

coypoop commented Nov 29, 2017

copying the freebsd/386 sysctl implementation as-is fixes this

@bradfitz
Copy link
Contributor Author

@coypoop, thanks!

For the record, the diff is:

localhost# git diff
diff --git a/src/runtime/sys_netbsd_386.s b/src/runtime/sys_netbsd_386.s
index af8c3aa485..8ee7b96ce7 100644
--- a/src/runtime/sys_netbsd_386.s
+++ b/src/runtime/sys_netbsd_386.s
@@ -375,10 +375,12 @@ TEXT runtime·sysctl(SB),NOSPLIT,$28
        MOVSL                           // arg 6 - newlen
        MOVL    $202, AX                // sys___sysctl
        INT     $0x80
-       JCC     3(PC)
+       JAE     4(PC)
        NEGL    AX
+       MOVL    AX, ret+24(FP)
        RET
        MOVL    $0, AX
+       MOVL    AX, ret+24(FP)
        RET
 
 GLOBL runtime·tlsoffset(SB),NOPTR,$4

@rsc fixed that for freebsd/386 in 25f6b02 where he wrote:

If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.

Indeed.

@gopherbot
Copy link

Change https://golang.org/cl/80515 mentions this issue: runtime: fix sysctl calling convention on netbsd/386

gopherbot pushed a commit to golang/build that referenced this issue Nov 29, 2017
It's still busted, but this will let other people debug.

Updates golang/go#22914
Updates golang/go#20852
Updates golang/go#19339

Change-Id: Iedc21417e56418dab6abd433574ffef012ae43f3
Reviewed-on: https://go-review.googlesource.com/80435
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@golang golang locked and limited conversation to collaborators Nov 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-NetBSD
Projects
None yet
Development

No branches or pull requests

4 participants