public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libbacktrace/112322] New: std::stacktrace fails
@ 2023-10-31 19:58 josopait at goopax dot com
  2023-10-31 20:06 ` [Bug libbacktrace/112322] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: josopait at goopax dot com @ 2023-10-31 19:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112322

            Bug ID: 112322
           Summary: std::stacktrace fails
           Product: gcc
           Version: 12.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libbacktrace
          Assignee: unassigned at gcc dot gnu.org
          Reporter: josopait at goopax dot com
                CC: ian at gcc dot gnu.org
  Target Milestone: ---

I installed gcc on gentoo linux:

EXTRA_ECONF="--enable-libstdcxx-backtrace=yes" emerge gcc

and compiled the following program:



#include <iostream>
#include <stacktrace>

int main()
{
  std::cout << std::stacktrace::current() << std::endl;
}

$ g++-13 -g -std=c++23 a.cpp -o a  -lstdc++_libbacktrace



When compiled with GCC 13 or GCC 14, the program output is weird:

$ ./a 
   0#      at :32764
   1#      at :32764
   2#      at :32764
   3#      at :32764
   4# 

The number 32764 changes randomly between program calls, in the range 32764 ..
32767.


When compiled with GCC 12, the program crashes with a segmentation fault:

(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x000055555555ad41 in elf_nodebug (state=<optimized out>, pc=<optimized
out>, callback=<optimized out>, data=<optimized out>, error_callback=<optimized
out>) at elf.c:585
#2  elf_nodebug (state=<optimized out>, pc=<optimized out>, callback=<optimized
out>, error_callback=<optimized out>, data=<optimized out>) at elf.c:565
#3  0x0000555555557c0f in std::stacktrace_entry::_M_get_info
(this=0x55555557e2b0, __desc=0x7fffffffdb60, __file=0x7fffffffdb80,
__line=0x7fffffffdb5c) at
/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/stacktrace:191
#4  0x0000555555557db2 in std::operator<< (__os=..., __f=...) at
/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/stacktrace:722
#5  0x00005555555585ce in std::operator<<
<std::allocator<std::stacktrace_entry> > (__os=..., __st=...) at
/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/stacktrace:737
#6  0x0000555555557492 in main () at a.cpp:8

Here, parameter `state` of function elf_nodebug points to:
(gdb) p *__state
$10 = {filename = 0x0, threaded = 1, lock = 0x0, fileline_fn = 0x55555555a5f0
<elf_nodebug>, fileline_data = 0x0, syminfo_fn = 0x55555555a5d0 <elf_nosyms>,
syminfo_data = 0x0, fileline_initialization_failed = 0, lock_alloc = 0,
freelist = 0x7ffff7fc4048}

and error_callback is NULL, which causes the segmentation fault.

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

* [Bug libbacktrace/112322] std::stacktrace fails
  2023-10-31 19:58 [Bug libbacktrace/112322] New: std::stacktrace fails josopait at goopax dot com
@ 2023-10-31 20:06 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-31 20:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112322

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup.

*** This bug has been marked as a duplicate of bug 111315 ***

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

end of thread, other threads:[~2023-10-31 20:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-31 19:58 [Bug libbacktrace/112322] New: std::stacktrace fails josopait at goopax dot com
2023-10-31 20:06 ` [Bug libbacktrace/112322] " pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).