public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgcc/100415] New: runtime error: reference binding to null pointer of type 'const struct __forced_unwind'
@ 2021-05-04 13:14 redi at gcc dot gnu.org
  2021-05-04 13:23 ` [Bug libstdc++/100415] " redi at gcc dot gnu.org
  2021-12-27 15:59 ` marc.mutz at hotmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2021-05-04 13:14 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100415
           Summary: runtime error: reference binding to null pointer of
                    type 'const struct __forced_unwind'
           Product: gcc
           Version: 10.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

#include <pthread.h>
#include <cxxabi.h>

int main()
{
  try
  {
    pthread_exit(0);
  } catch (const __cxxabiv1::__forced_unwind&)
  {
    throw;
  }
}

This produces a UBsan error:

$ g++ -fsanitize=undefined fu.C
$ ./a.out
fu.C:9:45: runtime error: reference binding to null pointer of type 'const
struct __forced_unwind'

Is libgcc creating a fake object at address 0?

Should __forced_unwind exceptions be caught by value instead?

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

* [Bug libstdc++/100415] runtime error: reference binding to null pointer of type 'const struct __forced_unwind'
  2021-05-04 13:14 [Bug libgcc/100415] New: runtime error: reference binding to null pointer of type 'const struct __forced_unwind' redi at gcc dot gnu.org
@ 2021-05-04 13:23 ` redi at gcc dot gnu.org
  2021-12-27 15:59 ` marc.mutz at hotmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2021-05-04 13:23 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|libgcc                      |libstdc++
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-05-04
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This happens in libsupc++/eh_personality.cc set the thrown type to
__forced_unwind:

      // During forced unwinding, match a magic exception type.
      if (actions & _UA_FORCE_UNWIND)
        {
          throw_type = &typeid(abi::__forced_unwind);
        }

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

* [Bug libstdc++/100415] runtime error: reference binding to null pointer of type 'const struct __forced_unwind'
  2021-05-04 13:14 [Bug libgcc/100415] New: runtime error: reference binding to null pointer of type 'const struct __forced_unwind' redi at gcc dot gnu.org
  2021-05-04 13:23 ` [Bug libstdc++/100415] " redi at gcc dot gnu.org
@ 2021-12-27 15:59 ` marc.mutz at hotmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: marc.mutz at hotmail dot com @ 2021-12-27 15:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Marc Mutz <marc.mutz at hotmail dot com> ---
Confirmed with 

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/d/gcc/11/libexec/gcc/x86_64-pc-linux-gnu/11.2.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/d/gcc/11
--enable-languages=c,c++,objc,fortran,obj-c++ --enable-release
--disable-multilib --program-suffix=-11 : (reconfigured) ../gcc/configure
--prefix=/d/gcc/11 --enable-languages=c,c++,objc,fortran,obj-c++
--enable-release --disable-multilib --program-suffix=-11
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.1 20211211 (GCC)

Work-around:
https://stackoverflow.com/questions/70378204/how-to-catch-abi-forced-unwind-while-keeping-ubsan-happy

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

end of thread, other threads:[~2021-12-27 15:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-04 13:14 [Bug libgcc/100415] New: runtime error: reference binding to null pointer of type 'const struct __forced_unwind' redi at gcc dot gnu.org
2021-05-04 13:23 ` [Bug libstdc++/100415] " redi at gcc dot gnu.org
2021-12-27 15:59 ` marc.mutz at hotmail dot com

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).