NetBSD Problem Report #58562
From www@netbsd.org Thu Aug 8 17:54:38 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits)
client-signature RSA-PSS (2048 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 8E7AA1A923E
for <gnats-bugs@gnats.NetBSD.org>; Thu, 8 Aug 2024 17:54:38 +0000 (UTC)
Message-Id: <20240808175437.4D6D31A9241@mollari.NetBSD.org>
Date: Thu, 8 Aug 2024 17:54:37 +0000 (UTC)
From: tkoeppe@google.com
Reply-To: tkoeppe@google.com
To: gnats-bugs@NetBSD.org
Subject: libedit should register signal handlers with SA_ONSTACK flag
X-Send-Pr-Version: www-1.0
>Number: 58562
>Category: lib
>Synopsis: libedit should register signal handlers with SA_ONSTACK flag
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Aug 08 17:55:00 +0000 2024
>Originator: Thomas Koeppe
>Release: head (75a90611a8098945540ed10d5831622fadcde4ae)
>Organization:
Google
>Environment:
Linux/Debian
>Description:
The signal handlers registered in lib/libedit/sig.c currently use the regular stack. I propose to set the SA_ONSTACK flag to allow the handler to use the alternate signal stack if one is available in the handling thread, but if there isn't, there is no effect.
This change would respect existing choices better. Specifically, this allows signal handlers to be set when the process includes a Go runtime, since Go enforces that all signal handlers in the process use the SA_ONSTACK flag (e.g. see https://github.com/golang/go/issues/20400).
>How-To-Repeat:
Include libedit in some binary that is running a Go runtime and install the signal handlers. This causes the Go runtime to abort with this error:
```
Handler for signal 28 registered without SA_ONSTACK: {Handler: <sig_handler>, Flags: [0x4000000]}
Go-incompatible signal handlers found; aborting.
```
>Fix:
See https://github.com/NetBSD/src/pull/40:
--- old/src/sig.c
+++ new/src/sig.c
@@ -167,7 +167,7 @@
struct sigaction osa, nsa;
nsa.sa_handler = sig_handler;
- nsa.sa_flags = 0;
+ nsa.sa_flags = SA_ONSTACK;
sigemptyset(&nsa.sa_mask);
(void) sigprocmask(SIG_BLOCK, &el->el_signal->sig_set, &oset);
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.