From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- .../ui/runtime/signal-alternate-stack-cleanup.rs | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/test/ui/runtime/signal-alternate-stack-cleanup.rs (limited to 'src/test/ui/runtime/signal-alternate-stack-cleanup.rs') diff --git a/src/test/ui/runtime/signal-alternate-stack-cleanup.rs b/src/test/ui/runtime/signal-alternate-stack-cleanup.rs new file mode 100644 index 000000000..8a6d73895 --- /dev/null +++ b/src/test/ui/runtime/signal-alternate-stack-cleanup.rs @@ -0,0 +1,37 @@ +// run-pass +// Previously memory for alternate signal stack have been unmapped during +// main thread exit while still being in use by signal handlers. This test +// triggers this situation by sending signal from atexit handler. +// +// ignore-wasm32-bare no libc +// ignore-windows +// ignore-sgx no libc +// ignore-vxworks no SIGWINCH in user space + +#![feature(rustc_private)] +extern crate libc; + +use libc::*; + +unsafe extern "C" fn signal_handler(signum: c_int, _: *mut siginfo_t, _: *mut c_void) { + assert_eq!(signum, SIGWINCH); +} + +extern "C" fn send_signal() { + unsafe { + raise(SIGWINCH); + } +} + +fn main() { + unsafe { + // Install signal handler that runs on alternate signal stack. + let mut action: sigaction = std::mem::zeroed(); + action.sa_flags = (SA_ONSTACK | SA_SIGINFO) as _; + action.sa_sigaction = signal_handler as sighandler_t; + sigaction(SIGWINCH, &action, std::ptr::null_mut()); + + // Send SIGWINCH on exit. + atexit(send_signal); + } +} -- cgit v1.2.3