wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
25.34k stars 1.22k forks source link

panic: runtime error: invalid memory address or nil pointer dereference #1407

Closed non-one closed 2 years ago

non-one commented 2 years ago

Description

change the go file and will trigger rebuild function. but in crash "panic: runtime error: invalid memory address or nil pointer dereference" 100%

To Reproduce

  1. make a app
  2. change the code in go file(for me, I add log.Println("-----------------------") code line
  3. crash happen

Expected behaviour

rebuild successfully

Screenshots

image

Attempted Fixes

No response

System Details

Wails CLI v2.0.0-beta.36

Scanning system - Please wait (this may take a long time)...Done.

System
------
OS:             Windows 10 Home    
Version:        2009 (Build: 19043)
ID:             21H1
Go Version:     go1.18
Platform:       windows
Architecture:   amd64

Wails
------
Version:        v2.0.0-beta.36

Dependency      Package Name    Status          Version
----------      ------------    ------          -------
WebView2        N/A             Installed       101.0.1210.47
npm             N/A             Installed       8.5.5
*upx            N/A             Available
*nsis           N/A             Available

* - Optional Dependency

Diagnosis
---------
Your system is ready for Wails development!
Optional package(s) installation details:
  - upx : Available at https://upx.github.io/
  - nsis : Available at https://nsis.sourceforge.io/Download

If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony

Additional context

crash_log.txt

leaanthony commented 2 years ago

Thanks for opening this. I couldn't reproduce locally. Could you please provide a bigger stack track? Thanks

non-one commented 2 years ago

I get some different track from wails dev console:

DEB | [DevWebServer] Websocket client 0xc000480d80 connected
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x8 pc=0x9ae6a1]

goroutine 73 [running]:
main.(*App).GetRuntimeInfo(0x1?)
        */pagetop/app.go:72 +0x41
reflect.Value.call({0xa7b320?, 0xc000004c60?, 0x0?}, {0xabef41, 0x4}, {0x15d6a28, 0x0, 0x9e45a0?})
        C:/Program Files/Go/src/reflect/value.go:556 +0x845
reflect.Value.Call({0xa7b320?, 0xc000004c60?, 0x4f2d9a?}, {0x15d6a28, 0x0, 0x0})
        C:/Program Files/Go/src/reflect/value.go:339 +0xbf
github.com/wailsapp/wails/v2/internal/binding.(*BoundMethod).Call(0xc00014c3f0, {0x15d6a28, 0x0, 0x9e45a0?})
        C:/Users/17100/go/pkg/mod/github.com/wailsapp/wails/v2@v2.0.0-beta.36/internal/binding/boundMethod.go:73 +0x16f
github.com/wailsapp/wails/v2/internal/frontend/dispatcher.(*Dispatcher).processCallMessage(0xc0002b0100, {0xc0004a2c40, 0x5f}, {0xc334e0, 0xc00029c0e0})
        C:/Users/17100/go/pkg/mod/github.com/wailsapp/wails/v2@v2.0.0-beta.36/internal/frontend/dispatcher/calls.go:45 +0x188
github.com/wailsapp/wails/v2/internal/frontend/dispatcher.(*Dispatcher).ProcessMessage(0xc0002973b0?, {0xc0004a2c40?, 0xc000484500?}, {0xc334e0?, 0xc00029c0e0?})
        C:/Users/17100/go/pkg/mod/github.com/wailsapp/wails/v2@v2.0.0-beta.36/internal/frontend/dispatcher/dispatcher.go:39 +0x5e
github.com/wailsapp/wails/v2/internal/frontend/desktop/windows.(*Frontend).processMessage.func1()
        C:/Users/17100/go/pkg/mod/github.com/wailsapp/wails/v2@v2.0.0-beta.36/internal/frontend/desktop/windows/frontend.go:494 +0x3e        
created by github.com/wailsapp/wails/v2/internal/frontend/desktop/windows.(*Frontend).processMessage
        C:/Users/17100/go/pkg/mod/github.com/wailsapp/wails/v2@v2.0.0-beta.36/internal/frontend/desktop/windows/frontend.go:493 +0x21b       
[0518/155819.529:ERROR:window_impl.cc(114)] Failed to unregister class Chrome_WidgetWin_0. Error = 0
Caught quit
Development mode exited

AND I am in another trouble, I cant open the wails windows,which means I have to see my project on chrome broswer start_log.txt

I Guess the wails hide the key error. I cant find what happended !

leaanthony commented 2 years ago

This looks like it's crashing in your own code "GetRuntimeInfo". Please provide a minimal reproducible example.

non-one commented 2 years ago

When I change go code. the frontend code will also be rebuild? Because in GetRuntimeInfo I use a variable which has been assigned a value in startup func. Frontend use GetRuntimeInfo in onMounted(). So I have a question: when wails trigger rebuild, the frontend will start before app.startup?

non-one commented 2 years ago

I am back. Because something worse. I run wails build and get the *.exe. But when I open executable file, nothing happend, no window #1305. wails devworks randomly and I can see the window. So I try to init another app from https://github.com/misitebao/wails-template-vue and find out that I can see the window after click the exe But wails dev not work, strange bug with no crash info. Tired...

stffabi commented 2 years ago

When using a debug build you should see the panic: 'wails build --debug'

I suspect this is a highly timing issue. There's currently no guarantee that the 'OnStartup' callback has been finished before the Webview loads the frontend. So depending on the timing it could happen that other frontend callbacks, e.g from OnMounted are executed before OnStartup has been finished. So you might see uninitialized variables.

leaanthony commented 2 years ago

Closing this as it's old. Please reopen if you can provide more info.

Osbornnnnn commented 2 years ago

I have this problem too. Tommorow i am give example code image