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: integer divide by zero check doesn't work on ARM #5805

Closed
gopherbot opened this issue Jun 28, 2013 · 9 comments
Closed

runtime: integer divide by zero check doesn't work on ARM #5805

gopherbot opened this issue Jun 28, 2013 · 9 comments
Milestone

Comments

@gopherbot
Copy link
Contributor

by capnm9:

hg id
166d946fa77f tip

This is a regression from go1.1.1.

func main() {
    a := 0
    b := 1 / a
    _ = b
}

uname -a
Linux rpi 3.6.11+ #474 PREEMPT Thu Jun 13 17:14:42 BST 2013 armv6l GNU/Linux

GOTRACEBACK=2; go run main.go 
runtime: unknown pc 0x1 at frame 11
fatal error: invalid stack

goroutine 1 [garbage collection]:
runtime.gc(0x0)
    /d/go/src/pkg/runtime/mgc0.c:2019 +0x1cc fp=0xb6eb5ecc
runtime.mallocgc(0x8, 0x0, 0x1, 0x1)
    /d/go/src/pkg/runtime/zmalloc_linux_arm.c:103 +0x1d4 fp=0xb6eb5f00
runtime.mal(0x8)
    /d/go/src/pkg/runtime/zmalloc_linux_arm.c:665 +0x40 fp=0xb6eb5f14
copyin(0x2da28, 0xb6eb5f54, 0xb6eb5f60)
    /d/go/src/pkg/runtime/iface.c:152 +0x64 fp=0xb6eb5f30
runtime.convT2E(0x2da28, 0x520c0, 0x16, 0x2da28, 0x16, ...)
    /d/go/src/pkg/runtime/iface.c:220 +0x44 fp=0xb6eb5f4c
runtime.newErrorString(0x520c0, 0x16, 0xb6eb5f7c)
    /d/go/src/pkg/runtime/error.go:74 +0x3c fp=0xb6eb5f64
runtime.panicstring(0x520c0)
    /d/go/src/pkg/runtime/panic.c:489 +0x7c fp=0xb6eb5f84
runtime.panicdivide()
    /d/go/src/pkg/runtime/vlrt_arm.c:40 +0x2c fp=0xb6eb5f8c
udiv(0x1)
    /d/go/src/pkg/runtime/vlop_arm.s:139 +0x9c fp=0xb6eb5f8c
main.main()
    /tmp/main.go:7 +0x38 fp=0xb6eb5f90
main.main()
    /tmp/main.go:7 +0x38 fp=0xb6eb5f94

goroutine 2 [runnable]:
runtime.MHeap_Scavenger()
    /d/go/src/pkg/runtime/mheap.c:438
runtime.goexit()
    /d/go/src/pkg/runtime/proc.c:1269
created by runtime.main
    /d/go/src/pkg/runtime/proc.c:165
exit status 2


----

/d/go1.1.1/bin/go run main.go 
panic: runtime error: integer divide by zero

goroutine 1 [running]:
runtime.panic(0x336e8, 0x10100008)
    /d/go1.1.1/src/pkg/runtime/panic.c:247 +0x128
runtime.panicstring(0x47088)
    /d/go1.1.1/src/pkg/runtime/panic.c:487 +0x8c
runtime.panicdivide()
    /d/go1.1.1/src/pkg/runtime/vlrt_arm.c:40 +0x28
udiv()
    /d/go1.1.1/src/pkg/runtime/vlop_arm.s:139 +0x9c
main.main()
    /tmp/main.go:7 +0x34

goroutine 2 [runnable]:
runtime.MHeap_Scavenger()
    /d/go1.1.1/src/pkg/runtime/mheap.c:421
runtime.goexit()
    /d/go1.1.1/src/pkg/runtime/proc.c:1223
created by runtime.main
    /d/go1.1.1/src/pkg/runtime/proc.c:165
exit status 2

----

uname -a
Linux t2t 3.8.0-23-generic #34-Ubuntu SMP Wed May 29 20:22:58 UTC 2013 x86_64 x86_64
x86_64 GNU/Linux

GOTRACEBACK=1; go run main.go 
panic: runtime error: integer divide by zero
[signal 0x8 code=0x1 addr=0x400c12 pc=0x400c12]

goroutine 1 [running]:
main.main()
    /tmp/main.go:7 +0x12

goroutine 2 [runnable]:
runtime.MHeap_Scavenger()
    /d/go/src/pkg/runtime/mheap.c:438
runtime.goexit()
    /d/go/src/pkg/runtime/proc.c:1269
created by runtime.main
    /d/go/src/pkg/runtime/proc.c:165
exit status 2
@robpike
Copy link
Contributor

robpike commented Jul 26, 2013

Comment 1:

Labels changed: added priority-soon, compilerbug, arch-arm, removed priority-triage.

Status changed to Accepted.

@robpike
Copy link
Contributor

robpike commented Jul 26, 2013

Comment 2:

Labels changed: removed compilerbug.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 3:

Labels changed: added go1.2.

@rsc
Copy link
Contributor

rsc commented Sep 11, 2013

Comment 4:

I think this is already fixed. I have added a test to the tree to find out.

Status changed to Started.

@ceh
Copy link
Contributor

ceh commented Sep 11, 2013

Comment 5:

Still broken for me.
$ uname -a
Linux nsa310 3.5.1 #1 Mon Sep 24 19:17:28 CEST 2012 armv5tel GNU/Linux
$ go version
go version devel +77a4d225cc7e Wed Sep 11 10:50:56 2013 +1000 linux/arm
$ cat issue5805.go
package main
func main() {
        a := 0
        b := 1 / a
        _ = b
}
$ go run issue5805.go
runtime: unknown argument frame size for udiv called from 0x10c38 [main.main]
fatal error: invalid stack
goroutine 1 [garbage collection]:
runtime.gc(0x0)
        /home/ceh/src/go/src/pkg/runtime/mgc0.c:2020 +0x1a0 fp=0xb6f37eac
runtime.mallocgc(0x8, 0x0, 0x0)
        /home/ceh/src/go/src/pkg/runtime/malloc.goc:143 +0x210 fp=0xb6f37ee8
runtime.mal(0x8)
        /home/ceh/src/go/src/pkg/runtime/malloc.goc:700 +0x38 fp=0xb6f37ef8
copyin(0x37150, 0xb6f37f38, 0xb6f37f44)
        /home/ceh/src/go/src/pkg/runtime/iface.c:153 +0x6c fp=0xb6f37f14
runtime.convT2E(0x37150, 0x64368, 0x16, 0x37150, 0x16)
        /home/ceh/src/go/src/pkg/runtime/iface.c:221 +0x44 fp=0xb6f37f30
runtime.newErrorString(0x64368, 0x16, 0xb6f37f60)
        /home/ceh/src/go/src/pkg/runtime/error.go:74 +0x3c fp=0xb6f37f48
runtime.panicstring(0x64368)
        /home/ceh/src/go/src/pkg/runtime/panic.c:519 +0x84 fp=0xb6f37f68
runtime.panicdivide()
        /home/ceh/src/go/src/pkg/runtime/vlrt_arm.c:42 +0x2c fp=0xb6f37f70
runtime: unknown argument frame size for udiv called from 0x10c38 [main.main]
udiv()
        /home/ceh/src/go/src/pkg/runtime/vlop_arm.s:171 +0x9c fp=0xb6f37f70
main.main()
        /home/ceh/src/issue5805.go:5 +0x38 fp=0xb6f37f7c
runtime: unexpected return pc for main.main called from 0x0
main.main()
        /home/ceh/src/issue5805.go:5 +0x38 fp=0xb6f37f88
goroutine 2 [runnable]:
runtime.MHeap_Scavenger()
        /home/ceh/src/go/src/pkg/runtime/mheap.c:439
runtime.goexit()
        /home/ceh/src/go/src/pkg/runtime/proc.c:1386
exit status 2

@rsc
Copy link
Contributor

rsc commented Sep 12, 2013

Comment 6:

This is a bit subtle to fix. udiv really needs to be changed not to depend quite so much
on the 5l code layout. I will do that for Go 1.2 but perhaps not for the first release
candidate. It will require writing some better divide tests.

@rsc
Copy link
Contributor

rsc commented Sep 16, 2013

Comment 7:

This issue was closed by revision b2794a1.

Status changed to Fixed.

@gopherbot
Copy link
Contributor Author

Comment 8:

CL https://golang.org/cl/13632048 references this issue.

@gopherbot
Copy link
Contributor Author

Comment 9:

CL https://golang.org/cl/13632048 references this issue.

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants