wails/v2/pkg/runtime
Lea Anthony 01b661f6a5
feat(v2): add runtime.ResetSignalHandlers() for Linux panic recovery (#4921)
* feat(v2): add runtime.ResetSignalHandlers() for Linux panic recovery

Add a new runtime function that allows users to reset signal handlers
before code that might panic from nil pointer dereferences.

On Linux, WebKit installs signal handlers without the SA_ONSTACK flag,
which prevents Go from properly recovering from panics caused by
SIGSEGV and other signals. This function adds SA_ONSTACK to the
relevant signal handlers (SIGSEGV, SIGBUS, SIGFPE, SIGABRT).

Usage:
```go
go func() {
    defer func() {
        if err := recover(); err != nil {
            log.Printf("Recovered: %v", err)
        }
    }()
    runtime.ResetSignalHandlers()
    // Code that might panic...
}()
```

The function is a no-op on macOS and Windows.

Fixes #3965

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(v2): add panic-recovery-test example

Add an example that demonstrates the Linux signal handler issue (#3965)
and verifies the fix using runtime.ResetSignalHandlers().

The example includes:
- A Greet function that triggers a nil pointer dereference after a delay
- Auto-call from frontend after 5 seconds
- README with reproduction steps

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 18:55:57 +11:00
..
browser.go feat: added a method to open the link in runtime(wailsapp#796) 2021-09-13 17:58:36 +08:00
clipboard.go Add common text clipboard support (#2228) 2023-01-05 16:41:07 +11:00
dialog.go [chore] lint fixes 2023-11-12 12:30:49 +11:00
draganddrop.go Fix Drag & Drop JS runtime (#3516) 2024-06-10 15:15:28 +10:00
events.go [chore] lint fixes 2023-11-12 12:30:49 +11:00
log.go [chore] lint fixes 2023-11-12 12:30:49 +11:00
menu.go [chore] lint fixes 2023-11-12 12:30:49 +11:00
runtime.go [chore] lint fixes 2023-11-12 12:30:49 +11:00
screen.go chore: fix function names in comment (#3383) 2024-04-09 17:19:06 -05:00
signal_linux.go feat(v2): add runtime.ResetSignalHandlers() for Linux panic recovery (#4921) 2026-02-02 18:55:57 +11:00
signal_other.go feat(v2): add runtime.ResetSignalHandlers() for Linux panic recovery (#4921) 2026-02-02 18:55:57 +11:00
window.go Add print functionality to v2 (#2822) 2023-09-06 07:55:36 +10:00