Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix AIX SIGSEGV for multi thread debugging.
@ 2026-06-22  7:03 Aditya Vidyadhar Kamath
  2026-06-23 11:57 ` Ulrich Weigand
  0 siblings, 1 reply; 3+ messages in thread
From: Aditya Vidyadhar Kamath @ 2026-06-22  7:03 UTC (permalink / raw)
  To: ulrich.weigand, simon.marchi, tom
  Cc: gdb-patches, Aditya.Kamath1, sangamesh.swamy

From: Aditya Kamath <Aditya.Kamath1@ibm.com>

When we run threads debugging in AIX we get,

Reading symbols from //gdb_tests/continue-pending-status...
(gdb) r
Starting program: /gdb_tests/continue-pending-status

Program received signal SIGSEGV, Segmentation fault.
0x7fe00008 in ?? ()
(gdb) q
A debugging session is active.

The reason being in AIX, the __pthread_init symbol returned by pthdb_session_pthreaded() is a function descriptor
and not the the direct code address. When GDB set a breakpoint using ms.value_address(), it was setting the breakpoint on the descriptor itself (0xf16365dc) rather than the actual function code. This caused the program to crash at an invalid address (0x7fe00008) when trying to execute from the descriptor location.

Debugging further and looking at the history, GDB-17.1/GDB-17.2 knew __pthread_init was a function because STABS symbol was recored with proper type, so we knew it was a function descriptor. After STABS removal symbol is recoreded without type and ms.value_address() returns descriptor address directly. 

if (cs->c_naux > 1 && ISFCN (cs->c_type))
      {
        fcn_start_addr = cs->c_value;
      }
case XMC_PR:
  /* A function entry point.  */
  
  record_minimal_symbol
    (reader, namestring, unrelocated_addr (symbol.n_value),
     sclass == C_HIDEXT ? mst_file_text : mst_text,
     symbol.n_scnum, objfile);
  misc_func_recorded = 1;
  break;

The code snippet above was one of the things STABS used to do that helped identify the entry point before.

This patch is the fix to the same.
---
 gdb/aix-thread.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 675d8d5070c..5ac71d22237 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -974,7 +974,12 @@ pd_enable (inferior *inf)
     = lookup_minimal_symbol (current_program_space, stub_name);
   if (ms.minsym == NULL)
     return;
-  data->pd_brk_addr = ms.value_address ();
+
+  /* On AIX, symbols can be function descriptors, so we need to resolve
+     them to get the actual code address.  */
+  if (!msymbol_is_function (ms.objfile, ms.minsym, &data->pd_brk_addr))
+    return;
+
   if (!create_thread_event_breakpoint (current_inferior ()->arch (),
 				       data->pd_brk_addr))
     return;
-- 
2.51.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix AIX SIGSEGV for multi thread debugging.
  2026-06-22  7:03 [PATCH] Fix AIX SIGSEGV for multi thread debugging Aditya Vidyadhar Kamath
@ 2026-06-23 11:57 ` Ulrich Weigand
  2026-06-24  9:07   ` Aditya Kamath
  0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Weigand @ 2026-06-23 11:57 UTC (permalink / raw)
  To: akamath996, tom, simon.marchi
  Cc: gdb-patches, SANGAMESH MALLAYYA, Aditya Kamath

Aditya Vidyadhar Kamath <akamath996@gmail.com> wrote:

>diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
>index 675d8d5070c..5ac71d22237 100644
>--- a/gdb/aix-thread.c
>+++ b/gdb/aix-thread.c
>@@ -974,7 +974,12 @@ pd_enable (inferior *inf)
>     = lookup_minimal_symbol (current_program_space, stub_name);
>   if (ms.minsym == NULL)
>     return;
>-  data->pd_brk_addr = ms.value_address ();
>+
>+  /* On AIX, symbols can be function descriptors, so we need to
>resolve
>+     them to get the actual code address.  */
>+  if (!msymbol_is_function (ms.objfile, ms.minsym, &data-
>>pd_brk_addr))
>+    return;
>+
>   if (!create_thread_event_breakpoint (current_inferior ()->arch (),
> 				       data->pd_brk_addr))
>     return;

This is OK.

Thanks,
Ulrich

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix AIX SIGSEGV for multi thread debugging.
  2026-06-23 11:57 ` Ulrich Weigand
@ 2026-06-24  9:07   ` Aditya Kamath
  0 siblings, 0 replies; 3+ messages in thread
From: Aditya Kamath @ 2026-06-24  9:07 UTC (permalink / raw)
  To: Ulrich Weigand, akamath996, tom, simon.marchi
  Cc: gdb-patches, SANGAMESH MALLAYYA

[-- Attachment #1: Type: text/plain, Size: 1401 bytes --]

Thank you.

I have pushed the same.

https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=5c5998bb64bf567ec9194208522a5fde7e6e01cb

From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
Date: Tuesday, 23 June 2026 at 5:27 PM
To: akamath996@gmail.com <akamath996@gmail.com>; tom@tromey.com <tom@tromey.com>; simon.marchi@polymtl.ca <simon.marchi@polymtl.ca>
Cc: gdb-patches@sourceware.org <gdb-patches@sourceware.org>; SANGAMESH MALLAYYA <sangamesh.swamy@in.ibm.com>; Aditya Kamath <Aditya.Kamath1@ibm.com>
Subject: Re: [PATCH] Fix AIX SIGSEGV for multi thread debugging.

Aditya Vidyadhar Kamath <akamath996@gmail.com> wrote:

>diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
>index 675d8d5070c..5ac71d22237 100644
>--- a/gdb/aix-thread.c
>+++ b/gdb/aix-thread.c
>@@ -974,7 +974,12 @@ pd_enable (inferior *inf)
>     = lookup_minimal_symbol (current_program_space, stub_name);
>   if (ms.minsym == NULL)
>     return;
>-  data->pd_brk_addr = ms.value_address ();
>+
>+  /* On AIX, symbols can be function descriptors, so we need to
>resolve
>+     them to get the actual code address.  */
>+  if (!msymbol_is_function (ms.objfile, ms.minsym, &data-
>>pd_brk_addr))
>+    return;
>+
>   if (!create_thread_event_breakpoint (current_inferior ()->arch (),
>                                      data->pd_brk_addr))
>     return;

This is OK.

Thanks,
Ulrich

[-- Attachment #2: Type: text/html, Size: 3634 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-24  9:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-22  7:03 [PATCH] Fix AIX SIGSEGV for multi thread debugging Aditya Vidyadhar Kamath
2026-06-23 11:57 ` Ulrich Weigand
2026-06-24  9:07   ` Aditya Kamath

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox