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

            Bug ID: 102993
           Summary: -mcf-protection=full produces segfaulting code when
                    targeting 32-bit x86 (i686)
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luke-jr+gccbugs at utopios dot org
  Target Milestone: ---

Generated programs, when throwing(catching?) an exception, jump to address 0
and crash.

Instead, the compiler should either reject the option, ignore it, or produce
working code.

#include <stdexcept>

void b(){
        throw std::runtime_error("hi");
}

int main(){
        try{
                b();
        }catch(...){}
}


(gdb) bt
#0  0x00401657 in ?? ()
#1  0x00401386 in ?? ()
#2  0x7b454882 in call_process_entry () from
/usr/lib/wine/../i386-linux-gnu/wine/kernel32.dll.so
#3  0x7b454cfc in start_process () from
/usr/lib/wine/../i386-linux-gnu/wine/kernel32.dll.so
#4  0x7b45488e in __wine_start_process () from
/usr/lib/wine/../i386-linux-gnu/wine/kernel32.dll.so
#5  0x00000000 in ?? ()

        }catch(...){
  401657:       89 04 24                mov    %eax,(%esp)
  40165a:       e8 49 00 00 00          call   4016a8 <___cxa_begin_catch>
  40165f:       c7 45 b8 ff ff ff ff    movl   $0xffffffff,-0x48(%ebp)
  401666:       e8 35 00 00 00          call   4016a0 <___cxa_end_catch>
  40166b:       eb d6                   jmp    401643 <_main+0x5e>
  40166d:       8d 45 b4                lea    -0x4c(%ebp),%eax
  401670:       89 04 24                mov    %eax,(%esp)
  401673:       e8 68 10 00 00          call   4026e0
<__Unwind_SjLj_Unregister>

Reply via email to