[New-bugs-announce] [issue43390] Set the SA_ONSTACK in PyOS_setsig to play well with other VMs like Golang

Gregory P. Smith report at bugs.python.org
Wed Mar 3 12:45:04 EST 2021


New submission from Gregory P. Smith <greg at krypto.org>:

PyOS_setsig currently sets the struct sigaction context.sa_flags = 0 before calling sigaction.

Other virtual machines such as Golang depend on signals using SA_ONSTACK such that signal handlers use a specially allocated stack that runtime sets up for reliability reasons as they use tiny stacks on normal threads.

SA_ONSTACK is a no-op flag in the typical case where no sigaltstack() call has been made to setup an alternate signal handling stack.  (as in 99.99% of all CPython applications)

When a C/C++ extension module is linked with cgo to call into a Golang library, doing this increases reliability.

As much as I try to dissuade anyone from creating and relying on hidden complexity multi-VM-hybrids in a single process like this, some people do, and this one line change helps.

Golang references:
  https://golang.org/pkg/os/signal/#hdr-Go_programs_that_use_cgo_or_SWIG
 and
  https://go-review.googlesource.com/c/go/+/298269/ (which clarifies that SA_RESTART is no longer a requirement. Good. Because Python won't get along well with that one.)

----------
assignee: gregory.p.smith
components: Interpreter Core
messages: 388036
nosy: gregory.p.smith
priority: normal
severity: normal
status: open
title: Set the SA_ONSTACK in PyOS_setsig to play well with other VMs like Golang
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43390>
_______________________________________


More information about the New-bugs-announce mailing list