gdb: patch sigaltstack

Avoid double allocation of alternative stack. Genode's sigaltstack variant
allocates the stack with alloc_secondary_stack. Disable the warning of
sigaltstack by using explicitly the nullptr in ss_sp.

Issue #5305
This commit is contained in:
Alexander Boettcher 2024-08-14 20:29:13 +02:00 committed by Christian Helmuth
parent 730f9ea437
commit 5537a26c25
4 changed files with 34 additions and 1 deletions

View File

@ -1 +1 @@
cb221184908b1a309ae71498720d3c8f1322d87c
0c95cb9312f8d0d7ad7f996c5df482d993dacf77

View File

@ -8,3 +8,4 @@ non_stop.patch
memory_map.patch
first_inferior.patch
symlinks.patch
sigaltstack.patch

View File

@ -0,0 +1,30 @@
sigaltstack.patch
diff --git a/gdbsupport/alt-stack.h b/gdbsupport/alt-stack.h
index 1424793..49332a6 100644
--- a/gdbsupport/alt-stack.h
+++ b/gdbsupport/alt-stack.h
@@ -37,7 +37,23 @@ class alternate_signal_stack
alternate_signal_stack ()
{
#ifdef HAVE_SIGALTSTACK
+
+#ifdef __GENODE__
+ /*
+ * Stack is allocated within sigaltstack invocation on Genode's Libc,
+ * see issue #5305
+ *
+ * The actual stack pointer is stored in m_stack, which is private,
+ * and thus seems not to be used directly by gdb code in any form.
+ *
+ * The m_stack is a smart pointer, which on destruction frees up the
+ * stored pointer (nullptr). xfree explicitly checks for nullptr and
+ * ignore the attempt, so it should be fine here to use nullptr.
+ */
+ m_stack.reset (nullptr);
+#else
m_stack.reset ((char *) xmalloc (SIGSTKSZ));
+#endif
stack_t stack;
stack.ss_sp = m_stack.get ();

View File

@ -8,6 +8,8 @@ CONFIGURE_ARGS += --program-prefix=$(PROGRAM_PREFIX) \
CONFIGURE_ARGS += --without-expat
CPPFLAGS += -DHAVE_LIBEXPAT=1
CPPFLAGS += -D__GENODE__
# prevent use of host libgmp in configure test
CONFIGURE_ARGS += --without-libgmp-prefix