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 #17

Open
tangliming opened this issue May 10, 2019 · 15 comments
Open

有时候启动程序会crash #17

tangliming opened this issue May 10, 2019 · 15 comments

Comments

@tangliming
Copy link

对下面的程序,运行,关闭,运行,关闭,重复多次以后,会crash。

var view *blink.WebView

func main() {
	exit := make(chan bool)
	//done := make(chan bool)
	blink.SetDebugMode(false)

	//初始化blink模块
	err := blink.InitBlink()
	if err != nil {
		log.Fatal(err)
	}
	blink.RegisterFileSystem("app", &assetfs.AssetFS{
		Asset:     Asset,
		AssetDir:  AssetDir,
		AssetInfo: AssetInfo,
	})

	//新建view,加载URL
	view = blink.NewWebView(false, 1060, 800)
	view.LoadURL("http://app/index.html")
	//view.LoadURL("http://localhost:8080/")
	view.MoveToCenter()
	view.ShowWindow()

	<-exit
}

以下是crash的信息

E:\gowork\src\gemini_scanner>gemini_scanner.exe
Exception 0xc0000005 0x1 0xc00006df48 0x76b698da
PC=0x76b698da
signal arrived during external code execution

syscall.Syscall(0x76b69910, 0x1, 0xc00006df38, 0x0, 0x0, 0x0, 0x0, 0x0)
        E:/Go/src/runtime/syscall_windows.go:186 +0xea
github.com/lxn/win.DispatchMessage(...)
        e:/gowork/src/github.com/lxn/win/user32.go:2000
github.com/raintean/blink.InitBlink.func2(0xc0001e8010, 0xf, 0x164d6de, 0x2)
        e:/gowork/src/github.com/raintean/blink/blink.go:91 +0x2e8
created by github.com/raintean/blink.InitBlink
        e:/gowork/src/github.com/raintean/blink/blink.go:55 +0x38c

goroutine 1 [chan receive, locked to thread]:
main.main()
        e:/gowork/src/gemini_scanner/main.go:157 +0x2cc

goroutine 21 [chan send]:
github.com/raintean/blink.(*WebView).SetWindowTitle(0xc0001fc0a0, 0xc000022140, 0x45)
        e:/gowork/src/github.com/raintean/blink/webview.go:158 +0xc3
github.com/raintean/blink.NewWebView.func4(0xc0001fc0a0, 0xc000022140, 0x45)
        e:/gowork/src/github.com/raintean/blink/webview.go:83 +0x56
reflect.Value.call(0x15cd2e0, 0x16762e0, 0x13, 0x164da79, 0x4, 0xc0001d2030, 0x2, 0x2, 0x0, 0x0, ...)
        E:/Go/src/reflect/value.go:447 +0x468
reflect.Value.Call(0x15cd2e0, 0x16762e0, 0x13, 0xc0001d2030, 0x2, 0x2, 0x0, 0x0, 0x0)
        E:/Go/src/reflect/value.go:308 +0xab
github.com/CHH/eventemitter.(*EventEmitter).Emit.func1(0xc000004040, 0xc0000241e0, 0x1650220, 0xc, 0x15cd2e0, 0x16762e0, 0x13)
        e:/gowork/src/github.com/CHH/eventemitter/eventemitter.go:81 +0x83
created by github.com/CHH/eventemitter.(*EventEmitter).Emit
        e:/gowork/src/github.com/CHH/eventemitter/eventemitter.go:80 +0x25d
rax     0x0
rbx     0x0
rcx     0x22d0a70
rdi     0x7fffff9c000
rsi     0xc00006df38
rbp     0xc00006deb8
rsp     0x5c3fd50
r8      0x5c3fcf0
r9      0x0
r10     0x1b233199
r11     0x0
r12     0x2676fa0
r13     0x0
r14     0x1
r15     0x3e8
rip     0x76b698da
rflags  0x10246
cs      0x33
fs      0x53
gs      0x2b
@raintean
Copy link
Owner

我这边测试了一下,并没有发现crash的情况
基于此,可以自行改造一下消息循环的代码(blink.go文件),看看结果会如何

if win.GetMessage(msg, 0, 0, 0) != 0 {
    //加入如下一行的判断
    if win.TranslateMessage(msg) {
            //是否传递下去
            next := true
            //拿到对应的webview
            view := getWebViewByHandle(msg.HWnd)
            if view != nil {
                next = view.processMessage(msg)
            }
            if next {
                win.DispatchMessage(msg)
            }
        }
    }

期待你的反馈结果

@raintean
Copy link
Owner

另外你这个问题是不是和 #15 有关

@faddei
Copy link

faddei commented May 13, 2019

Exception 0xc0000005 0x1 0x0 0x58f82156
PC=0x58f82156
signal arrived during external code execution

syscall.Syscall(0x76195060, 0x1, 0x14437fa8, 0x0, 0x0, 0x0, 0x0, 0x0)
        C:/Go/src/runtime/syscall_windows.go:184 +0xbb
github.com/lxn/win.DispatchMessage(0x14437fa8, 0x14437fa8)
        E:/workSpace/go/src/github.com/lxn/win/user32.go:2163 +0x57
github.com/raintean/blink.InitBlink.func2(0x14584000, 0x36)
        E:/workSpace/go/src/github.com/raintean/blink/blink.go:90 +0x219
created by github.com/raintean/blink.InitBlink
        E:/workSpace/go/src/github.com/raintean/blink/blink.go:54 +0x2c6

goroutine 1 [chan receive, 3 minutes]:
main.main()
        E:/workSpace/go/src/blink/main.go:35 +0x1e0

goroutine 4 [chan send, 3 minutes]:
github.com/CHH/eventemitter.(*EventEmitter).Emit.func1(0x14404080, 0x14416240, 0x1176780, 0xd, 0x1106d00, 0x11a26ec, 0x13)
        E:/workSpace/go/src/github.com/CHH/eventemitter/eventemitter.go:88 +0x167
created by github.com/CHH/eventemitter.(*EventEmitter).Emit
        E:/workSpace/go/src/github.com/CHH/eventemitter/eventemitter.go:80 +0x298

goroutine 36 [chan send, 3 minutes]:
github.com/CHH/eventemitter.(*EventEmitter).Emit.func1(0x1457a1d0, 0x145847c0, 0x1176780, 0xd, 0x1106d00, 0x11a26ec, 0x13)
        E:/workSpace/go/src/github.com/CHH/eventemitter/eventemitter.go:88 +0x167
created by github.com/CHH/eventemitter.(*EventEmitter).Emit
        E:/workSpace/go/src/github.com/CHH/eventemitter/eventemitter.go:80 +0x298

goroutine 35 [chan send, 3 minutes]:
github.com/CHH/eventemitter.(*EventEmitter).Emit.func1(0x1457a180, 0x14584740, 0x117614c, 0xc, 0x1110260, 0x11a26f0, 0x13)
        E:/workSpace/go/src/github.com/CHH/eventemitter/eventemitter.go:88 +0x167
created by github.com/CHH/eventemitter.(*EventEmitter).Emit
        E:/workSpace/go/src/github.com/CHH/eventemitter/eventemitter.go:80 +0x298

goroutine 37 [chan send, 3 minutes]:
github.com/CHH/eventemitter.(*EventEmitter).Emit.func1(0x1457a220, 0x14584800, 0x117614c, 0xc, 0x1110260, 0x11a26f0, 0x13)
        E:/workSpace/go/src/github.com/CHH/eventemitter/eventemitter.go:88 +0x167
created by github.com/CHH/eventemitter.(*EventEmitter).Emit
        E:/workSpace/go/src/github.com/CHH/eventemitter/eventemitter.go:80 +0x298

goroutine 38 [chan send, 3 minutes]:
github.com/CHH/eventemitter.(*EventEmitter).Emit.func1(0x1457a240, 0x14584880, 0x1176780, 0xd, 0x1106d00, 0x11a26ec, 0x13)
        E:/workSpace/go/src/github.com/CHH/eventemitter/eventemitter.go:88 +0x167
created by github.com/CHH/eventemitter.(*EventEmitter).Emit
        E:/workSpace/go/src/github.com/CHH/eventemitter/eventemitter.go:80 +0x298

goroutine 5 [chan send, 3 minutes]:
github.com/CHH/eventemitter.(*EventEmitter).Emit.func1(0x144040a0, 0x14416280, 0x117614c, 0xc, 0x1110260, 0x11a26f0, 0x13)
        E:/workSpace/go/src/github.com/CHH/eventemitter/eventemitter.go:88 +0x167
created by github.com/CHH/eventemitter.(*EventEmitter).Emit
        E:/workSpace/go/src/github.com/CHH/eventemitter/eventemitter.go:80 +0x298

goroutine 6 [chan send, 3 minutes]:
github.com/CHH/eventemitter.(*EventEmitter).Emit.func1(0x144040c0, 0x14416300, 0x1176780, 0xd, 0x1106d00, 0x11a26ec, 0x13)
        E:/workSpace/go/src/github.com/CHH/eventemitter/eventemitter.go:88 +0x167
created by github.com/CHH/eventemitter.(*EventEmitter).Emit
        E:/workSpace/go/src/github.com/CHH/eventemitter/eventemitter.go:80 +0x298

goroutine 7 [chan send, 3 minutes]:
github.com/CHH/eventemitter.(*EventEmitter).Emit.func1(0x144040e0, 0x14416340, 0x117614c, 0xc, 0x1110260, 0x11a26f0, 0x13)
        E:/workSpace/go/src/github.com/CHH/eventemitter/eventemitter.go:88 +0x167
created by github.com/CHH/eventemitter.(*EventEmitter).Emit
        E:/workSpace/go/src/github.com/CHH/eventemitter/eventemitter.go:80 +0x298
eax     0x34f8efa4
ebx     0x75bd5e40
ecx     0x5981c758
edx     0x0
edi     0x48ca00
esi     0x0
ebp     0x34f8ef8c
esp     0x34f8ef7c
eip     0x58f82156
eflags  0x210202
cs      0x23
fs      0x53
gs      0x2b

@tangliming
Copy link
Author

另外你这个问题是不是和 #15 有关

并不是,因为我修改了blink.go

func InitBlink() error {
	TempPath := "./"

@tangliming
Copy link
Author

 if win.TranslateMessage(msg) {

感谢,我会修改测试下看看是否有改善

@tangliming
Copy link
Author

 if win.TranslateMessage(msg) {

感谢,我会修改测试下看看是否有改善

貌似死循环了,导致窗口白板无法响应任何消息

@raintean
Copy link
Owner

 if win.TranslateMessage(msg) {

感谢,我会修改测试下看看是否有改善

貌似死循环了,导致窗口白板无法响应任何消息

windows的消息循环机制我并不是特别清楚, 因为我很少弄原生开发, 刚刚看了TranslateMessage函数的作用, 发现他其实是用来做虚拟键的转换的, 这样子写确实会出现卡住的问题.
另外看了一下出错时的堆栈信息, 发现是DispatchMessage方法调用时出的错. 错误码: 0xc0000005 网上说是非法内存访问, 所以我感觉可能是MSG本身有问题.具体未知.

@raintean
Copy link
Owner

查阅windows文档, 如下
image
所以我觉得可能需要加一个-1的判断, 不知道有没有效果, 因为我这边无法复现, 如果你那边复现比较简单. 可以试一下加一个-1的逻辑, 如果问题解决, 发一个PR. 感谢!

@tangliming
Copy link
Author

查阅windows文档, 如下
image
所以我觉得可能需要加一个-1的判断, 不知道有没有效果, 因为我这边无法复现, 如果你那边复现比较简单. 可以试一下加一个-1的逻辑, 如果问题解决, 发一个PR. 感谢!

测试了下,并没有解决问题,并且再crash发生的时候,GetMessage的返回值是1

@raintean
Copy link
Owner

好的 我持续跟进

@tangliming
Copy link
Author

好的 我持续跟进

我测试的系统是win7,golang版本是1.12,不知道会不会有关系

@raintean
Copy link
Owner

我装个win7 测试一下

@zhuwei
Copy link

zhuwei commented Jun 21, 2019

这个问题我这边也出现。闪退,奇特的是启动闪退几率很低(同台电脑上多次启动)。但还是会发生,有log显示释放dll的时候出现。

@dilidili-chaochao
Copy link

			msg := &win.MSG{}
			if win.GetMessage(msg, 0, 0, 0) != 0 {
				if msg == nil {
					fmt.Println(msg)
				}

这样改下就没闪退过了,不知道为什么,加个很短的sleep好像也行

@raintean
Copy link
Owner

			msg := &win.MSG{}
			if win.GetMessage(msg, 0, 0, 0) != 0 {
				if msg == nil {
					fmt.Println(msg)
				}

这样改下就没闪退过了,不知道为什么,加个很短的sleep好像也行

重要的应该不是这个判断, 因为msg是在上面赋值的, 整个过程中没有改变, 按道理不可能为空的.

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