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

app crash if "invalid memory address or nil pointer dereference" #3965

Open
mediawall opened this issue Dec 23, 2024 · 3 comments
Open

app crash if "invalid memory address or nil pointer dereference" #3965

mediawall opened this issue Dec 23, 2024 · 3 comments
Labels
Bug Something isn't working

Comments

@mediawall
Copy link

Description

signal 11 received but handler not on signal stack
mp.gsignal stack [0xc000170000 0xc000178000], mp.g0 stack [0x7f738a1ffe08 0x7f738a9ffa08], sp=0xc000920798
fatal error: non-Go code set up signal handler without SA_ONSTACK flag

refer issue: #2152

To Reproduce

add following code to Greet method:

func (g *GreetService) Greet(name string) string {

	go func() {
		defer func() {
			if err := recover(); err != nil {
				fmt.Printf("------------------------------%#v\n", err)
			}
		}()
		time.Sleep(5 * time.Second)
		var t *time.Time
		log.Println(t.Unix())
	}()

	return "Hello " + name + "!"
}

Expected behaviour

exception is recovered.
if put the method in test function, the exception could be recovered.

Screenshots

No response

Attempted Fixes

No response

System Details

# Wails
Version         | v2.9.2
Package Manager | apt   

# System
┌──────────────────────────────────────────────────────────────────────────────────┐
| OS           | Ubuntu                                                            |
| Version      | 24.04                                                             |
| ID           | ubuntu                                                            |
| Go Version   | go1.23.2                                                          |
| Platform     | linux                                                             |
| Architecture | amd64                                                             |
| CPU          | Intel(R) Core(TM) i7-6850K CPU @ 3.60GHz                          |
| GPU 1        | Unknown                                                           |
| GPU 2        | GP102 [GeForce GTX 1080 Ti] (NVIDIA Corporation) - Driver: nvidia |
| Memory       | 98GB                                                              |
└──────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌────────────────────────────────────────────────────────────────────┐
| Dependency | Package Name    | Status    | Version                 |
| *docker    | docker.io       | Available | 26.1.3-0ubuntu1~24.04.1 |
| gcc        | build-essential | Installed | 13.3.0                  |
| libgtk-3   | libgtk-3-dev    | Available | 3.24.41-4ubuntu1.2      |
| libwebkit  | Unknown         | Not Found |                         |
| npm        | npm             | Installed | 10.9.0                  |
| *nsis      | nsis            | Installed | v3.09-4                 |
| pkg-config | pkg-config      | Installed | 1.8.1                   |
└───────────────────── * - Optional Dependency ──────────────────────┘

# Diagnosis
Required package(s) installation details: 
  - libgtk-3: sudo apt install libgtk-3-dev
  - libwebkit: sudo apt install libwebkit2gtk-4.0-dev

Optional package(s) installation details: 
  - docker: sudo apt install docker.io

Additional context

No response

@0xsimulacra
Copy link

0xsimulacra commented Jan 6, 2025

Can comfirm it happen to me too, I had a fucntion which was called fro; javascript to go and it required access to an ele;ent in the App struct wich I forgot to intilize and cost me some time to figure out that this complex error message was only due to a nil pointer derefrence.

The function called from frontend was this:


func (app *App) GoCautionUpdateStart(force bool) bool {
    if !app.state.Caution.IsRunning.CompareAndSwap(false, true) {
        if force {
            app.state.Caution.StopRunSignal <- struct{}{}
        }
        return false
    }
    return true
}

Nor app.state.Caution.IsRunning, nor app.state.Caution.StopRunSignal were intilized and the error was:

signal 11 received but handler not on signal stack
mp.gsignal stack [0xc000606000 0xc00060e000], mp.g0 stack [0x7fb5fa7fcdd8 0x7fb5faffc9d8], sp=0xc0002823a8
fatal error: non-Go code set up signal handler without SA_ONSTACK flag

runtime stack:
runtime.throw({0x1706d6d?, 0x0?})
	/usr/local/goroot/src/runtime/panic.go:1067 +0x48 fp=0xc000282318 sp=0xc0002822e8 pc=0x481748
runtime.sigNotOnStack(0xb, 0xc0002823a8, 0xc000600008)
	/usr/local/goroot/src/runtime/signal_unix.go:1108 +0x145 fp=0xc000282348 sp=0xc000282318 pc=0x4615c5
runtime.adjustSignalStack(0xb, 0xc000600008, 0xc0002823d0)
	/usr/local/goroot/src/runtime/signal_unix.go:592 +0x15c fp=0xc0002823a8 sp=0xc000282348 pc=0x46057c
runtime.sigtrampgo(0xb, 0xc0002826b0, 0xc000282580)
	/usr/local/goroot/src/runtime/signal_unix.go:480 +0xd5 fp=0xc000282420 sp=0xc0002823a8 pc=0x460195
runtime.sigtramp()
	/usr/local/goroot/src/runtime/sys_linux_amd64.s:352 +0x46 fp=0xc000282470 sp=0xc000282420 pc=0x48af66

goroutine 17 gp=0xc000006700 m=1 mp=0xc000026708 [syscall, locked to thread]:
runtime.goexit({})
	/usr/local/goroot/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc00008cfe8 sp=0xc00008cfe0 pc=0x489441

goroutine 1 gp=0xc0000061c0 m=8 mp=0xc000580008 [syscall, locked to thread]:
runtime.cgocall(0x155c5d0, 0xc000267cc8)
.
.
.

The error is very confusing and scary in way, I tought I wouldn't be able to use goroutines, channels, or atomics in wails app.

@leaanthony
Copy link
Member

I'm not sure what the ask is from the Wails project on this one. Everything that's described is Go related.

@mediawall
Copy link
Author

I'm not sure what the ask is from the Wails project on this one. Everything that's described is Go related.

I am not sure the reason that recover can't capture the error, usually it should be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants