[Bug backtrace/33256] New: incorrect prototype in backtrace when using GCC's cleanup attribute (GCC 8)

vincent-srcware at vinc17 dot net sourceware-bugzilla@sourceware.org
Wed Aug 6 15:33:45 GMT 2025


https://sourceware.org/bugzilla/show_bug.cgi?id=33256

            Bug ID: 33256
           Summary: incorrect prototype in backtrace when using GCC's
                    cleanup attribute (GCC 8)
           Product: gdb
           Version: 16.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: backtrace
          Assignee: unassigned at sourceware dot org
          Reporter: vincent-srcware at vinc17 dot net
  Target Milestone: ---

Created attachment 16232
  --> https://sourceware.org/bugzilla/attachment.cgi?id=16232&action=edit
executable generated by gcc-8

gdb shows an incorrect prototype in backtrace when using GCC's cleanup
attribute, visible when the testcase below is compiled with GCC 8. It is not
clear whether this was actually a bug in GCC 8 fixed in GCC 9 and later or this
is a bug in gdb that is not longer visible when the testcase below is compiled
with GCC 9 and later but which may still appear with other C codes.

I had initially reported this bug in 2011 at

  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=624465

(hence the use of GCC 8 at that time).

The testcase:

#include <stdio.h>
#include <stdlib.h>

int fct (int *x, int y, int z)
{
  void log_cleanup (int *time)
  {
    fprintf (stderr, "x=%d\n", *x);
  }
  int log_time __attribute__ ((cleanup (log_cleanup)));

  *x = y;
  abort ();
  return 0;
}

int main (void)
{
  int x;

  fct (&x, 17, 1);
  return 0;
}

compiled with "gcc-8 -Wall -g tst.c -o tst" under Debian/unstable (this is an
old machine where I have kept various GCC versions).

cventin% gdb tst
GNU gdb (Debian 16.3-1) 16.3
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from tst...
(gdb) run
Starting program: /home/vlefevre/tst
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6,
    no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
warning: 44     ./nptl/pthread_kill.c: No such file or directory
(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>,
    signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
#1  0x00007ffff7e309ff in __pthread_kill_internal (threadid=<optimized out>,
    signo=6) at ./nptl/pthread_kill.c:89
#2  0x00007ffff7ddbcc2 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/posix/raise.c:26
#3  0x00007ffff7dc44ac in __GI_abort () at ./stdlib/abort.c:73
#4  0x0000555555555140 in fct (y=y@entry=17, z=z@entry=1) at tst.c:13
#5  0x0000555555555158 in main () at tst.c:21
(gdb)

One can see that the x is absent from fct in #4.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Gdb-prs mailing list