Move to final version of upstream patch for non-constant SIGSTKSZ
NOTE: I did not build this package because it will cause dependency problems (requiring every other OCaml package in F35 to be rebuilt). If there is a mass rebuild of Rawhide then that would be a good time to rebuild it.
This commit is contained in:
parent
b8653f50ff
commit
129153b851
@ -23,5 +23,5 @@ index 07e2eda1a..340508a60 100644
|
||||
> ocamlmklibconfig.ml
|
||||
|
||||
--
|
||||
2.29.0.rc2
|
||||
2.32.0
|
||||
|
||||
|
@ -23,5 +23,5 @@ index 83455a3b6..213392b25 100644
|
||||
|
||||
# Enable SSE2 on x86 mingw to avoid using 80-bit registers.
|
||||
--
|
||||
2.29.0.rc2
|
||||
2.32.0
|
||||
|
||||
|
@ -39,5 +39,5 @@ index 213392b25..c7e594b5d 100644
|
||||
# We first compute default values for as and aspp
|
||||
# If values have been given by the user then they take precedence over
|
||||
--
|
||||
2.29.0.rc2
|
||||
2.32.0
|
||||
|
||||
|
103
0004-Dynamically-allocate-the-alternate-signal-stack-1026.patch
Normal file
103
0004-Dynamically-allocate-the-alternate-signal-stack-1026.patch
Normal file
@ -0,0 +1,103 @@
|
||||
From 3104d92743614f8f52039e0520116af4179880a5 Mon Sep 17 00:00:00 2001
|
||||
From: Xavier Leroy <xavierleroy@users.noreply.github.com>
|
||||
Date: Fri, 5 Mar 2021 19:14:07 +0100
|
||||
Subject: [PATCH 4/4] Dynamically allocate the alternate signal stack (#10266)
|
||||
|
||||
In Glibc 2.34 and later, SIGSTKSZ may not be a compile-time constant.
|
||||
It is no longer possible to statically allocate the alternate signal
|
||||
stack for the main thread, as we've been doing for the last 25 years.
|
||||
|
||||
This commit implements dynamic allocation of the alternate signal stack
|
||||
even for the main thread. It reuses the code already in place to allocate
|
||||
the alternate signal stack for other threads.
|
||||
|
||||
Fixes: #10250.
|
||||
(cherry picked from commit fc9534746bf5d08a4c109f22e344cf49d5d46d54)
|
||||
---
|
||||
runtime/caml/signals.h | 2 +-
|
||||
runtime/signals_byt.c | 2 +-
|
||||
runtime/signals_nat.c | 25 ++++++++++++++-----------
|
||||
3 files changed, 16 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/runtime/caml/signals.h b/runtime/caml/signals.h
|
||||
index 3ff152c26..285dbd7fe 100644
|
||||
--- a/runtime/caml/signals.h
|
||||
+++ b/runtime/caml/signals.h
|
||||
@@ -87,7 +87,7 @@ value caml_do_pending_actions_exn (void);
|
||||
value caml_process_pending_actions_with_root (value extra_root); // raises
|
||||
value caml_process_pending_actions_with_root_exn (value extra_root);
|
||||
int caml_set_signal_action(int signo, int action);
|
||||
-CAMLextern void caml_setup_stack_overflow_detection(void);
|
||||
+CAMLextern int caml_setup_stack_overflow_detection(void);
|
||||
|
||||
CAMLextern void (*caml_enter_blocking_section_hook)(void);
|
||||
CAMLextern void (*caml_leave_blocking_section_hook)(void);
|
||||
diff --git a/runtime/signals_byt.c b/runtime/signals_byt.c
|
||||
index 2183142da..38eb5e3a4 100644
|
||||
--- a/runtime/signals_byt.c
|
||||
+++ b/runtime/signals_byt.c
|
||||
@@ -81,4 +81,4 @@ int caml_set_signal_action(int signo, int action)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-CAMLexport void caml_setup_stack_overflow_detection(void) {}
|
||||
+CAMLexport int caml_setup_stack_overflow_detection(void) { return 0; }
|
||||
diff --git a/runtime/signals_nat.c b/runtime/signals_nat.c
|
||||
index 8b64ab452..2b4004860 100644
|
||||
--- a/runtime/signals_nat.c
|
||||
+++ b/runtime/signals_nat.c
|
||||
@@ -181,8 +181,6 @@ DECLARE_SIGNAL_HANDLER(trap_handler)
|
||||
#error "CONTEXT_SP is required if HAS_STACK_OVERFLOW_DETECTION is defined"
|
||||
#endif
|
||||
|
||||
-static char sig_alt_stack[SIGSTKSZ];
|
||||
-
|
||||
/* Code compiled with ocamlopt never accesses more than
|
||||
EXTRA_STACK bytes below the stack pointer. */
|
||||
#define EXTRA_STACK 256
|
||||
@@ -276,28 +274,33 @@ void caml_init_signals(void)
|
||||
#endif
|
||||
|
||||
#ifdef HAS_STACK_OVERFLOW_DETECTION
|
||||
- {
|
||||
- stack_t stk;
|
||||
+ if (caml_setup_stack_overflow_detection() != -1) {
|
||||
struct sigaction act;
|
||||
- stk.ss_sp = sig_alt_stack;
|
||||
- stk.ss_size = SIGSTKSZ;
|
||||
- stk.ss_flags = 0;
|
||||
SET_SIGACT(act, segv_handler);
|
||||
act.sa_flags |= SA_ONSTACK | SA_NODEFER;
|
||||
sigemptyset(&act.sa_mask);
|
||||
- if (sigaltstack(&stk, NULL) == 0) { sigaction(SIGSEGV, &act, NULL); }
|
||||
+ sigaction(SIGSEGV, &act, NULL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
-CAMLexport void caml_setup_stack_overflow_detection(void)
|
||||
+/* Allocate and select an alternate stack for handling signals,
|
||||
+ especially SIGSEGV signals.
|
||||
+ Each thread needs its own alternate stack.
|
||||
+ The alternate stack used to be statically-allocated for the main thread,
|
||||
+ but this is incompatible with Glibc 2.34 and newer, where SIGSTKSZ
|
||||
+ may not be a compile-time constant (issue #10250). */
|
||||
+
|
||||
+CAMLexport int caml_setup_stack_overflow_detection(void)
|
||||
{
|
||||
#ifdef HAS_STACK_OVERFLOW_DETECTION
|
||||
stack_t stk;
|
||||
stk.ss_sp = malloc(SIGSTKSZ);
|
||||
+ if (stk.ss_sp == NULL) return -1;
|
||||
stk.ss_size = SIGSTKSZ;
|
||||
stk.ss_flags = 0;
|
||||
- if (stk.ss_sp)
|
||||
- sigaltstack(&stk, NULL);
|
||||
+ return sigaltstack(&stk, NULL);
|
||||
+#else
|
||||
+ return 0;
|
||||
#endif
|
||||
}
|
||||
--
|
||||
2.32.0
|
||||
|
@ -1,39 +0,0 @@
|
||||
From dfb5e954a04f59b0456cc4c0ddf3acaf22e0ff07 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Sun, 28 Feb 2021 20:45:47 +0000
|
||||
Subject: [PATCH 4/4] Workaround for glibc non-constant SIGSTKSZ
|
||||
|
||||
https://github.com/ocaml/ocaml/issues/10250
|
||||
|
||||
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
||||
---
|
||||
runtime/signals_nat.c | 12 ++++++++++++
|
||||
1 file changed, 12 insertions(+)
|
||||
|
||||
diff --git a/runtime/signals_nat.c b/runtime/signals_nat.c
|
||||
index 8b64ab452..7f0a97513 100644
|
||||
--- a/runtime/signals_nat.c
|
||||
+++ b/runtime/signals_nat.c
|
||||
@@ -181,7 +181,19 @@ DECLARE_SIGNAL_HANDLER(trap_handler)
|
||||
#error "CONTEXT_SP is required if HAS_STACK_OVERFLOW_DETECTION is defined"
|
||||
#endif
|
||||
|
||||
+#ifndef __GLIBC__
|
||||
static char sig_alt_stack[SIGSTKSZ];
|
||||
+#else
|
||||
+/* glibc 2.34 has non-constant SIGSTKSZ */
|
||||
+static char *sig_alt_stack;
|
||||
+
|
||||
+static void allocate_sig_alt_stack(void) __attribute__((constructor));
|
||||
+static void
|
||||
+allocate_sig_alt_stack(void)
|
||||
+{
|
||||
+ sig_alt_stack = malloc(SIGSTKSZ);
|
||||
+}
|
||||
+#endif
|
||||
|
||||
/* Code compiled with ocamlopt never accesses more than
|
||||
EXTRA_STACK bytes below the stack pointer. */
|
||||
--
|
||||
2.29.0.rc2
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
Name: ocaml
|
||||
Version: 4.12.0
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
|
||||
Summary: OCaml compiler and programming environment
|
||||
|
||||
@ -60,7 +60,7 @@ Source0: https://caml.inria.fr/pub/distrib/ocaml-4.12/ocaml-%{version}.ta
|
||||
Patch0001: 0001-Don-t-add-rpaths-to-libraries.patch
|
||||
Patch0002: 0002-configure-Allow-user-defined-C-compiler-flags.patch
|
||||
Patch0003: 0003-configure-Remove-incorrect-assumption-about-cross-co.patch
|
||||
Patch0004: 0004-Workaround-for-glibc-non-constant-SIGSTKSZ.patch
|
||||
Patch0004: 0004-Dynamically-allocate-the-alternate-signal-stack-1026.patch
|
||||
|
||||
BuildRequires: make
|
||||
BuildRequires: git
|
||||
@ -370,6 +370,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/eventlog_metadata
|
||||
|
||||
|
||||
%changelog
|
||||
* Wed Jun 23 2021 Richard W.M. Jones <rjones@redhat.com> - 4.12.0-2
|
||||
- Move to final version of upstream patch for non-constant SIGSTKSZ
|
||||
|
||||
* Sun Feb 28 2021 Richard W.M. Jones <rjones@redhat.com> - 4.12.0-1
|
||||
- OCaml 4.12.0 release (RHBZ#1893381).
|
||||
- Workaround for glibc non-constant SIGSTKSZ
|
||||
|
Loading…
Reference in New Issue
Block a user