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

            Bug ID: 85397
           Summary: -mcet -fcf-protection doesn't work with label in
                    nested function
           Product: gcc
           Version: 8.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
                CC: igor.v.tsimbalist at intel dot com
            Blocks: 81652
  Target Milestone: ---
            Target: x86_64

[hjl@gnu-cet-1 cet-3]$ cat x.i
int
s(int i)
{
  if(i>0)
    {
      __label__ l1;
      int f(int i)
        {
          if(i==2)
            goto l1;
          return 0;
        }
      return f(i);
l1:
      ;
    }
  return 1;
}

int
x(void)
{
  return s(0)==1&&s(1)==0&&s(2)==1;
}
int
main()
{
  if(x()!=1)
    __builtin_abort();
  return 0;
}
[hjl@gnu-cet-1 cet-3]$ make
gcc -O2 -mcet -fcf-protection -S x.i
gcc -g -O2 -mcet -fcf-protection -o x x.s
./x
make: *** [Makefile:10: all] Segmentation fault
[hjl@gnu-cet-1 cet-3]$ gdb x
GNU gdb (GDB) Fedora 8.1-11.fc28
Copyright (C) 2018 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-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://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 x...done.
(gdb) r
Starting program: /export/home/hjl/bugs/gcc/cet-3/x 
Missing separate debuginfos, use: dnf debuginfo-install
glibc-2.27-8.6.fc28.x86_64

Program received signal SIGSEGV, Segmentation fault.
s () at x.s:76
76              ret
(gdb) bt
#0  s () at x.s:76
#1  0x0000000000401238 in x () at x.s:136
#2  0x000000000040106d in main () at x.s:157
(gdb)


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81652
[Bug 81652] [meta-bug] -fcf-protection=full -mcet bugs

Reply via email to