Skip to content

Commit ef782b7

Browse files
leaanthonyclaude
andauthored
fix(linux): stop forcing SA_ONSTACK on SIGUSR1 to prevent WebKit freeze (#5530)
WebKit's JavaScriptCore uses SIGUSR1 to suspend/resume threads for conservative GC stack scanning. The signal-handler fix added in alpha.97 (#5507) re-applied SA_ONSTACK to every signal it touched, including SIGUSR1. Once JSC installs its own SIGUSR1 handler it owns the signal (Go no longer handles it), so forcing SA_ONSTACK makes that handler run on Go's alternate signal stack, breaking GC thread synchronisation. This froze the WebKit UI during idle garbage collection (most visibly with the inspector open) while the Go backend kept running. Remove fix_signal(SIGUSR1) from install_signal_handlers in v3 (GTK4 + GTK3) and v2. The genuine #5506 fix for SIGSEGV/SIGBUS (which Go needs SA_ONSTACK for) is unaffected. Fixes #5527 https://claude.ai/code/session_01AtT1CjDNRArXv1eddXte2a Co-authored-by: Claude <noreply@anthropic.com>
1 parent 37ec248 commit ef782b7

4 files changed

Lines changed: 19 additions & 9 deletions

File tree

v2/internal/frontend/desktop/linux/frontend.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,12 @@ static void install_signal_handlers()
6565
#if defined(SIGSEGV)
6666
fix_signal(SIGSEGV);
6767
#endif
68-
#if defined(SIGUSR1)
69-
fix_signal(SIGUSR1);
70-
#endif
68+
// NOTE: Do NOT add SA_ONSTACK to SIGUSR1. WebKit's JavaScriptCore uses
69+
// SIGUSR1 to suspend/resume threads for conservative GC stack scanning.
70+
// Once JSC installs its own SIGUSR1 handler it owns the signal (Go no
71+
// longer handles it), and forcing SA_ONSTACK makes that handler run on
72+
// Go's alternate signal stack, breaking GC thread synchronisation and
73+
// freezing WebKit during idle collection. See issue #5527.
7174
#if defined(SIGXCPU)
7275
fix_signal(SIGXCPU);
7376
#endif

v3/UNRELEASED_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ After processing, the content will be moved to the main changelog and this file
2323

2424
## Fixed
2525
<!-- Bug fixes -->
26+
- Fix WebKit UI freeze on Linux when idle (e.g. with the inspector open) by no longer forcing `SA_ONSTACK` on `SIGUSR1`, which broke JavaScriptCore's GC thread synchronisation (#5527)
2627

2728
## Deprecated
2829
<!-- Soon-to-be removed features -->

v3/pkg/application/linux_cgo.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,12 @@ void install_signal_handlers(void) {
114114
#if defined(SIGSEGV)
115115
fix_signal(SIGSEGV);
116116
#endif
117-
#if defined(SIGUSR1)
118-
fix_signal(SIGUSR1);
119-
#endif
117+
// NOTE: Do NOT add SA_ONSTACK to SIGUSR1. WebKit's JavaScriptCore uses
118+
// SIGUSR1 to suspend/resume threads for conservative GC stack scanning.
119+
// Once JSC installs its own SIGUSR1 handler it owns the signal (Go no
120+
// longer handles it), and forcing SA_ONSTACK makes that handler run on
121+
// Go's alternate signal stack, breaking GC thread synchronisation and
122+
// freezing WebKit during idle collection. See issue #5527.
120123
#if defined(SIGXCPU)
121124
fix_signal(SIGXCPU);
122125
#endif

v3/pkg/application/linux_cgo_gtk3.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,12 @@ static void install_signal_handlers() {
222222
#if defined(SIGSEGV)
223223
fix_signal(SIGSEGV);
224224
#endif
225-
#if defined(SIGUSR1)
226-
fix_signal(SIGUSR1);
227-
#endif
225+
// NOTE: Do NOT add SA_ONSTACK to SIGUSR1. WebKit's JavaScriptCore uses
226+
// SIGUSR1 to suspend/resume threads for conservative GC stack scanning.
227+
// Once JSC installs its own SIGUSR1 handler it owns the signal (Go no
228+
// longer handles it), and forcing SA_ONSTACK makes that handler run on
229+
// Go's alternate signal stack, breaking GC thread synchronisation and
230+
// freezing WebKit during idle collection. See issue #5527.
228231
#if defined(SIGXCPU)
229232
fix_signal(SIGXCPU);
230233
#endif

0 commit comments

Comments
 (0)