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

x/exp/shiny: panic is not panicky #13963

jnjackins opened this issue Jan 15, 2016 · 3 comments

x/exp/shiny: panic is not panicky #13963

jnjackins opened this issue Jan 15, 2016 · 3 comments


Copy link

@jnjackins jnjackins commented Jan 15, 2016

go version devel +c5a2f36 Thu Jan 14 20:57:21 2016 +0000 darwin/amd64

Once a window has been initialized, any panics (either by calling panic() or some other means) do not exit the program or print a stack trace, but rather cause the program to hang. If the window has been published, the cursor becomes a spinning beachball.

$ git diff
diff --git a/shiny/example/basic/main.go b/shiny/example/basic/main.go
index d427b34..f88d34b 100644
--- a/shiny/example/basic/main.go
+++ b/shiny/example/basic/main.go
@@ -40,6 +40,8 @@ func main() {
                defer w.Release()

+               panic("help!")
                winSize := image.Point{256, 256}
                b, err := s.NewBuffer(winSize)
                if err != nil {
$ go build main.go 
$ ./main 
(hangs forever)

cc @crawshaw @nigeltao

Copy link

@nigeltao nigeltao commented Jan 15, 2016

Darwin means I'm assigning this to crawshaw.

Copy link

@crawshaw crawshaw commented Jan 20, 2016

With a similar panic inserted and go version devel +57b1e55 Sat Jan 9 03:30:40 2016 +0000 darwin/amd64 I get:

$ go run ./example/basic/main.go 
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x40c03a0]

goroutine 1 [running, locked to thread]:, 0x50190d0, 0x1)
    /Users/crawshaw/src/ +0x130, 0x50190d0, 0x1) +0x35 +0x31, 0x0, 0x0)
    /Users/crawshaw/src/ +0x18a
    /Users/crawshaw/src/ +0x30
    /Users/crawshaw/src/ +0x21
    /Users/crawshaw/src/ +0x21
    /Users/crawshaw/src/ +0x23
exit status 2

Which is not right, but is a little more information.

@jnjackins do you get a stack trace if you send a SIGQUIT?

Copy link
Contributor Author

@jnjackins jnjackins commented Jan 20, 2016

Hi David. Thanks for having a look.

I couldn't reproduce the issue the same way this time either, but I was able to reproduce it by inserting a panic into the handling of paint.Event in the tile example program:

diff --git a/shiny/example/tile/main.go b/shiny/example/tile/main.go
index ad30f68..58fdc4c 100644
--- a/shiny/example/tile/main.go
+++ b/shiny/example/tile/main.go
@@ -85,6 +85,7 @@ func main() {

                        case paint.Event:
+                               panic("hello")
                                var wg sync.WaitGroup
                                for y := -(origin.Y & 0xff); y < sz.HeightPx; y += 256 {

And here is the stack trace I got by sending SIGQUIT:

$ ./main 
PC=0x405c76b m=0
signal arrived during cgo execution

goroutine 1 [chan receive, locked to thread]:
runtime.mach_semaphore_wait(0xc800001003, 0x422fd00, 0x40322c2, 0x40e3480, 0x7fff5fbfd690, 0x422fd00, 0x4050819, 0xffffffffffffffff, 0x419f450, 0x7fff5fbfd6a4, ...)
    /Users/jnj/src/go/src/runtime/sys_darwin_amd64.s:411 +0xb fp=0x7fff5fbfd638 sp=0x7fff5fbfd630
runtime.semasleep1(0xffffffffffffffff, 0x419f450)
    /Users/jnj/src/go/src/runtime/os1_darwin.go:418 +0xdf fp=0x7fff5fbfd670 sp=0x7fff5fbfd638
    /Users/jnj/src/go/src/runtime/os1_darwin.go:434 +0x29 fp=0x7fff5fbfd690 sp=0x7fff5fbfd670
    /Users/jnj/src/go/src/runtime/asm_amd64.s:307 +0xab fp=0x7fff5fbfd698 sp=0x7fff5fbfd690
runtime.semasleep(0xffffffffffffffff, 0x0)
    /Users/jnj/src/go/src/runtime/os1_darwin.go:435 +0x36 fp=0x7fff5fbfd6c8 sp=0x7fff5fbfd698
    /Users/jnj/src/go/src/runtime/lock_sema.go:166 +0xed fp=0x7fff5fbfd700 sp=0x7fff5fbfd6c8
    /Users/jnj/src/go/src/runtime/proc.go:1674 +0xae fp=0x7fff5fbfd720 sp=0x7fff5fbfd700
    /Users/jnj/src/go/src/runtime/proc.go:2018 +0x6e fp=0x7fff5fbfd758 sp=0x7fff5fbfd720
    /Users/jnj/src/go/src/runtime/proc.go:2125 +0x18b fp=0x7fff5fbfd780 sp=0x7fff5fbfd758
    /Users/jnj/src/go/src/runtime/asm_amd64.s:233 +0x5b fp=0x7fff5fbfd790 sp=0x7fff5fbfd780

goroutine 17 [syscall, locked to thread]:
    /Users/jnj/src/go/src/runtime/asm_amd64.s:1998 +0x1

goroutine 5 [syscall, locked to thread]: +0x36
    /Users/jnj/src/ +0x21*windowImpl).Release(0xc820078000)
    /Users/jnj/src/ +0x9d
main.main.func1(0x476b318, 0x422f940)
    /Users/jnj/src/ +0x641
    /Users/jnj/src/ +0x47
created by
    /Users/jnj/src/ +0x2b

goroutine 18 [select, locked to thread]:, 0x1)
    /Users/jnj/src/ +0x482
created by
    /Users/jnj/src/ +0x117

rax    0xe
rbx    0x4230040
rcx    0x7fff5fbfd630
rdx    0x7fff5fbfd6a8
rdi    0x1003
rsi    0x7fff5fbfd648
rbp    0x1003
rsp    0x7fff5fbfd630
r8     0x80008ff
r9     0x0
r10    0x700000429068
r11    0x286
r12    0x2c
r13    0x419e60c
r14    0x0
r15    0x8
rip    0x405c76b
rflags 0x286
cs     0x7
fs     0x0
gs     0x0

I wonder if there is a deadlock occurring when the panic comes at an unlucky time, which would explain why it's difficult to reproduce consistently.

@bradfitz bradfitz added this to the Unreleased milestone Jan 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants