From 434fe1a4092e12e5b518ef0716dc5b315e06118d Mon Sep 17 00:00:00 2001 From: Stefan Liebler Date: Tue, 7 Apr 2020 16:14:40 +0200 Subject: [PATCH] S/390: Fix layout of struct sigaction_t The ordering of some fields in struct sigaction on s390x (64bit) differs compared to s390 and other architectures. This patch adjusts this order according to the definition of /sysdeps/unix/sysv/linux/s390/bits/sigaction.h Without this fix e.g. the call sigaction( suspendSignalNumber, &sigusr1, null ) in thread.d leads to setting the sa_restorer field to 0xffffffffffffffff. In case a signal, the signal handler returns to this address and the process stops with a SIGILL. This was observable in several execution testcases on s390x: libphobos.druntime/core/thread.d libphobos.druntime_shared/core/thread.d libphobos.thread/tlsgc_sections.d libphobos.allocations/tls_gc_integration.d libphobos.phobos/std/parallelism.d libphobos.phobos_shared/std/parallelism.d libphobos.shared/host.c libphobos.shared/linkD.c libphobos.shared/linkDR.c libphobos.shared/link_linkdep.d libphobos.shared/load.d libphobos.shared/loadDR.c libphobos.shared/load_linkdep.d libphobos.shared/load_loaddep.d libphobos/ChangeLog: 2020-04-07 Stefan Liebler * libdruntime/core/sys/posix/signal.d: Add struct sigaction_t for SystemZ. --- libphobos/ChangeLog | 5 ++ libphobos/libdruntime/core/sys/posix/signal.d | 47 +++++++++++++++---- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/libphobos/ChangeLog b/libphobos/ChangeLog index d3edfd3c29a..3791d4a5ef6 100644 --- a/libphobos/ChangeLog +++ b/libphobos/ChangeLog @@ -1,3 +1,8 @@ +2020-04-07 Stefan Liebler + + * libdruntime/core/sys/posix/signal.d: + Add struct sigaction_t for SystemZ. + 2020-03-16 Iain Buclaw PR d/92792 diff --git a/libphobos/libdruntime/core/sys/posix/signal.d b/libphobos/libdruntime/core/sys/posix/signal.d index ed3985eee4d..5abcdac1355 100644 --- a/libphobos/libdruntime/core/sys/posix/signal.d +++ b/libphobos/libdruntime/core/sys/posix/signal.d @@ -575,24 +575,51 @@ else version (CRuntime_Glibc) { - struct sigaction_t + version (SystemZ) { - static if ( true /* __USE_POSIX199309 */ ) + struct sigaction_t { - union + static if ( true /* __USE_POSIX199309 */ ) + { + union + { + sigfn_t sa_handler; + sigactfn_t sa_sigaction; + } + } + else { sigfn_t sa_handler; - sigactfn_t sa_sigaction; } + int __glibc_reserved0; + int sa_flags; + + void function() sa_restorer; + + sigset_t sa_mask; } - else + } + else + { + struct sigaction_t { - sigfn_t sa_handler; - } - sigset_t sa_mask; - int sa_flags; + static if ( true /* __USE_POSIX199309 */ ) + { + union + { + sigfn_t sa_handler; + sigactfn_t sa_sigaction; + } + } + else + { + sigfn_t sa_handler; + } + sigset_t sa_mask; + int sa_flags; - void function() sa_restorer; + void function() sa_restorer; + } } } else version (CRuntime_Musl) -- 2.30.2