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

Crash when resizing examples/imageviewer #2

Open
hajimehoshi opened this issue May 6, 2019 · 5 comments
Open

Crash when resizing examples/imageviewer #2

hajimehoshi opened this issue May 6, 2019 · 5 comments

Comments

@hajimehoshi
Copy link

$ go run ./imageviewer/                                                                                                                                                                                                                       
fatal error: unexpected signal during runtime execution                                                                                                                                                                                       
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7fff2df567b4]                                                                                                                                                                  
                                                                                                                                                                                                                                              
runtime stack:                                                                                                                                                                                                                                
runtime.throw(0x4217912, 0x2a)                                                                                                                                                                                                                
        /usr/local/go/src/runtime/panic.go:617 +0x72                                                                                                                                                                                          
runtime.sigpanic()                                                                                                                                                                                                                            
        /usr/local/go/src/runtime/signal_unix.go:374 +0x4a9                                                                                                                                                                                   
                                                                                                                                                                                                                                              
goroutine 3 [syscall, locked to thread]:                                                                                                                                                                                                      
runtime.cgocall(0x413c830, 0xc000376c40, 0xc000001200)                                                                                                                                                                                        
        /usr/local/go/src/runtime/cgocall.go:128 +0x5b fp=0xc000376c10 sp=0xc000376bd8 pc=0x400591b                                                                                                                                           
github.com/go-gl/gl/v2.1/gl._Cfunc_glowDrawPixels(0x7fff3e7ab7d1, 0x25800000332, 0x140100001908, 0xc001186000)                                                                                                                                
        _cgo_gotypes.go:13546 +0x45 fp=0xc000376c40 sp=0xc000376c10 pc=0x40baf55                                                                                                                                                              
github.com/go-gl/gl/v2.1/gl.DrawPixels.func1(0x25800000332, 0x140100001908, 0xc001186000)                                                                                                                                                     
        /Users/hajimehoshi/go/pkg/mod/github.com/go-gl/[email protected]/v2.1/gl/package.go:20431 +0x90 fp=0xc000376c80 sp=0xc000376c40 pc=0x40fa730                                                                      
github.com/go-gl/gl/v2.1/gl.DrawPixels(0x25800000332, 0x140100001908, 0xc001186000)                                                                                                                                                           
        /Users/hajimehoshi/go/pkg/mod/github.com/go-gl/[email protected]/v2.1/gl/package.go:20431 +0x4b fp=0xc000376ca8 sp=0xc000376c80 pc=0x40bb56b                                                                      
github.com/faiface/gui/win.(*Win).openGLFlush(0xc000152040, 0x0, 0x0, 0x332, 0x258)                                                                                                                                                           
        /Users/hajimehoshi/gui/win/win.go:324 +0x3d3 fp=0xc000376dc0 sp=0xc000376ca8 pc=0x4101943                                                                                                                                             
github.com/faiface/gui/win.(*Win).openGLThread(0xc000152040)                                                                                                                                                                                  
        /Users/hajimehoshi/gui/win/win.go:280 +0x547 fp=0xc000376fc0 sp=0xc000376dc0 pc=0x41011b7                                                                                                                                             
github.com/faiface/gui/win.New.func2(0xc000152040)                                                                                                                                                                                            
        /Users/hajimehoshi/gui/win/win.go:84 +0x30 fp=0xc000376fd8 sp=0xc000376fc0 pc=0x4101b10                                                                                                                                               
runtime.goexit()                                                                                                                                                                                                                              
        /usr/local/go/src/runtime/asm_amd64.s:1337 +0x1 fp=0xc000376fe0 sp=0xc000376fd8 pc=0x40569b1                                                                                                                                          
created by github.com/faiface/gui/win.New                                                                                                                                                                                                     
        /Users/hajimehoshi/gui/win/win.go:82 +0x331      
@faiface
Copy link
Owner

faiface commented May 6, 2019

Is this still happening? When exactly does it happen?

@hajimehoshi
Copy link
Author

Not sure. In the latest version, I've not reproduce this yet.

@peterhellberg
Copy link

peterhellberg commented May 7, 2019

I've not gotten it to crash, but CPU usage is >100% when quickly resizing the window (seems like we need some event debouncing)

Oh, and while resizing the window (under macOS El Capitan) it contains garbled image data (probably from the graphics card buffer) but switches back to the correct image once finished resizing.

@neilpa
Copy link

neilpa commented Jul 21, 2019

I'm able to repro this with a trivial app on macOS Mojave while resizing. I also see the GPU artifacts that @peterhellberg mentioned.

 > cat resize.go
package main

import (
	"github.com/faiface/gui/win"
	"github.com/faiface/mainthread"
)

func run() {
	w, err := win.New(win.Title("resize test"), win.Resizable())
	if err != nil {
		panic(err)
	}

	for event := range w.Events() {
		switch event.(type) {
		case win.WiClose:
			close(w.Draw())
		}
	}
}

func main() {
	mainthread.Run(run)
}

> go run resize.go
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7fff3ce03a34]

runtime stack:
runtime.throw(0x41be431, 0x2a)
	/usr/local/Cellar/go/1.12.1/libexec/src/runtime/panic.go:617 +0x72
runtime.sigpanic()
	/usr/local/Cellar/go/1.12.1/libexec/src/runtime/signal_unix.go:374 +0x4a9

goroutine 4 [syscall, locked to thread]:
runtime.cgocall(0x40f3010, 0xc000208ca8, 0x140100001908)
	/usr/local/Cellar/go/1.12.1/libexec/src/runtime/cgocall.go:128 +0x5b fp=0xc000208c78 sp=0xc000208c40 pc=0x40048cb
github.com/go-gl/gl/v2.1/gl._Cfunc_glowFlush(0x7fff3c23ba53)
	_cgo_gotypes.go:14753 +0x41 fp=0xc000208ca8 sp=0xc000208c78 pc=0x40a4d11
github.com/go-gl/gl/v2.1/gl.Flush(...)
	/Users/neilpankey/go/pkg/mod/github.com/go-gl/[email protected]/v2.1/gl/package.go:20709
github.com/faiface/gui/win.(*Win).openGLFlush(0xc0000c6000, 0x0, 0x0, 0x2ba, 0x202)
	/Users/neilpankey/go/pkg/mod/github.com/faiface/[email protected]/win/win.go:357 +0x3e4 fp=0xc000208dc0 sp=0xc000208ca8 pc=0x40ec024
github.com/faiface/gui/win.(*Win).openGLThread(0xc0000c6000)
	/Users/neilpankey/go/pkg/mod/github.com/faiface/[email protected]/win/win.go:306 +0x547 fp=0xc000208fc0 sp=0xc000208dc0 pc=0x40eb887
github.com/faiface/gui/win.New.func3(0xc0000c6000)
	/Users/neilpankey/go/pkg/mod/github.com/faiface/[email protected]/win/win.go:120 +0x30 fp=0xc000208fd8 sp=0xc000208fc0 pc=0x40ec360
runtime.goexit()
	/usr/local/Cellar/go/1.12.1/libexec/src/runtime/asm_amd64.s:1337 +0x1 fp=0xc000208fe0 sp=0xc000208fd8 pc=0x4055d11
created by github.com/faiface/gui/win.New
	/Users/neilpankey/go/pkg/mod/github.com/faiface/[email protected]/win/win.go:118 +0x3b0

goroutine 1 [chan send, locked to thread]:
github.com/faiface/gui/win.(*Win).eventThread.func6(0xc0000d6000, 0x2ba, 0x204)
	/Users/neilpankey/go/pkg/mod/github.com/faiface/[email protected]/win/win.go:254 +0xb6
github.com/go-gl/glfw/v3.2/glfw.goFramebufferSizeCB(0x73276d0, 0x204000002ba)
	/Users/neilpankey/go/pkg/mod/github.com/go-gl/[email protected]/v3.2/glfw/window.go:192 +0x61
github.com/go-gl/glfw/v3.2/glfw._cgoexpwrap_e91ead9994e1_goFramebufferSizeCB(0x73276d0, 0x204000002ba)
	_cgo_gotypes.go:2185 +0x3b
github.com/go-gl/glfw/v3.2/glfw._Cfunc_glfwWaitEventsTimeout(0x3fa1111111111111)
	_cgo_gotypes.go:1946 +0x41
github.com/go-gl/glfw/v3.2/glfw.WaitEventsTimeout(0x3fa1111111111111)
	/Users/neilpankey/go/pkg/mod/github.com/go-gl/[email protected]/v3.2/glfw/window.go:823 +0x2d
github.com/faiface/gui/win.(*Win).eventThread(0xc0000c6000)
	/Users/neilpankey/go/pkg/mod/github.com/faiface/[email protected]/win/win.go:272 +0x303
github.com/faiface/mainthread.Run(0x41bfb30)
	/Users/neilpankey/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:44 +0xbd
main.main()
	/Users/neilpankey/code/neilpa/edit/resize.go:25 +0x2d

goroutine 34 [chan receive]:
main.run()
	/Users/neilpankey/code/neilpa/edit/resize.go:16 +0xcc
github.com/faiface/mainthread.Run.func1(0x41bfb30, 0xc0000c0000)
	/Users/neilpankey/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:37 +0x27
created by github.com/faiface/mainthread.Run
	/Users/neilpankey/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:36 +0xb1

goroutine 35 [chan receive]:
github.com/faiface/gui.MakeEventsChan.func1(0xc0000c00c0, 0xc0000c0060)
	/Users/neilpankey/go/pkg/mod/github.com/faiface/[email protected]/event.go:44 +0x311
created by github.com/faiface/gui.MakeEventsChan
	/Users/neilpankey/go/pkg/mod/github.com/faiface/[email protected]/event.go:40 +0x89
exit status 2

@changkun
Copy link

changkun commented Jul 7, 2021

It looks like if the window is resized in a different size, but glDrawPixels still send the old size, then the crash will happen.
(because rendering and events are in different threads and happen concurrently)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants