WebView crashes program with some websites
kjk opened this issue · 7 comments
> go version
go version go1.8.1 windows/amd64
Win 10 64bit.
The program below crashes the program i.e. the window shows up briefly, then disappears. The part after mainTmpl.Run()
doesn't seem to run.
It doesn't crash if I change URL to https://blog.kowalczyk.info/software/
IE (the old one) seems to be displaying the page just fine.
I ran it under the debugger (from Visual Studio Code) but it didn't give me anything so don't know how to debug it further.
package main
import (
"fmt"
"github.com/lxn/walk"
"github.com/lxn/walk/declarative"
)
func main() {
var main *walk.MainWindow
var wv *walk.WebView
fmt.Printf("Starting\n")
mainTmpl := declarative.MainWindow{
AssignTo: &main,
Title: "Test",
MinSize: declarative.Size{600, 400},
Layout: declarative.VBox{},
Children: []declarative.Widget{
declarative.WebView{
AssignTo: &wv,
Name: "wv",
URL: "https://blog.kowalczyk.info",
},
},
}
n, err := mainTmpl.Run()
fmt.Printf("Run() returned %d, %s\n", n, err)
}
The same crash happens with webview example when given https://blog.kowalczyk.info
url.
After reading #261, I tried:
1. added dummy cgo import to force large stack import _ "runtime/cgo"
2. compile in 32bit with:
run.ps1
:
$env:GOARCH=386
go build
.\webview.exe
Neither fixed the crash.
Also, I didn't actually get fatal: morestack on g0
, the program just silently vanishes.
Your example program works for me on Windows 10 64bit with go version go1.8.3 windows/386
.
As it seems you just edited the webview example, so it should not be a manifest problem.
No idea why it's failing, sorry.
I can confirm this is a small stack issue as discussed in #261
I ran the exe under windbg and it crashed due to stack overflow in mshtml.
I then edited the .exe to increase the stack to 1 MB, in powershell:
& "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\editbin.exe" /stack:1048576 FindFilesGo.exe
and it fixed the problem.
I can also confirm that if I build in 32-bit, it doesn't crash either ($env:GOARCH = "386"
) (which is why it doesn't crash for you).
I imagine both 32 and 64 bit builds are unstable due to small stack (I think go linker sets 128 kB) but 64 bit more so. And not only with webview - any OS code that uses lots of stack will trigger this.
I think it's worth documenting in the docs.
Using editbin.exe
to edit the exe after build is an easy workaround. Stack size is encoded in .exe PE headers, so it would be relatively easy to write a pure go program that changes it (editbin.exe
is part of Visual Studio).
I've opened golang/go#20975 that asks for a go linker option to change stack size.
Thanks for your investigations and initiative.
Until the problem is fixed in Go, there is a section about this in the README.
Hey @kjk and @lxn, I've had some time to investigate this issue a bit further and posted my findings on golang/go#20975. Maybe you can have a look at what I've written there just to make sure I'm not misrepresenting anything.
This has been in issue in go that is fixed in go 1.12 (even earlier, I think)