This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/86560] New: FAIL: c-c++-common/asan/swapcontext-test-1.c


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

            Bug ID: 86560
           Summary: FAIL: c-c++-common/asan/swapcontext-test-1.c
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
  Target Milestone: ---
            Target: i386,x86-64

When CET is enabled, I got

FAIL: c-c++-common/asan/swapcontext-test-1.c   -O0  execution test
FAIL: c-c++-common/asan/swapcontext-test-1.c   -O1  execution test
FAIL: c-c++-common/asan/swapcontext-test-1.c   -O2  execution test
FAIL: c-c++-common/asan/swapcontext-test-1.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
FAIL: c-c++-common/asan/swapcontext-test-1.c   -O3 -g  execution test
FAIL: c-c++-common/asan/swapcontext-test-1.c   -Os  execution test
FAIL: c-c++-common/asan/swapcontext-test-1.c   -O0  execution test
FAIL: c-c++-common/asan/swapcontext-test-1.c   -O1  execution test
FAIL: c-c++-common/asan/swapcontext-test-1.c   -O2  execution test
FAIL: c-c++-common/asan/swapcontext-test-1.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution test
FAIL: c-c++-common/asan/swapcontext-test-1.c   -O3 -g  execution test
FAIL: c-c++-common/asan/swapcontext-test-1.c   -Os  execution test

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff71fbef3 in __interceptor_swapcontext (oucp=0x404300 <orig_context>, 
    ucp=0x4046e0 <child_context>)
    at
/export/gnu/import/git/sources/gcc/libsanitizer/asan/asan_interceptors.cc:270
270       int res = REAL(swapcontext)(oucp, ucp);
(gdb) disass
Dump of assembler code for function __interceptor_swapcontext(ucontext_t*,
ucontext_t*):
   0x00007ffff71fbeb0 <+0>:     endbr64 
   0x00007ffff71fbeb4 <+4>:     push   %rbp
   0x00007ffff71fbeb5 <+5>:     mov    %rdi,%rbp
   0x00007ffff71fbeb8 <+8>:     push   %rbx
   0x00007ffff71fbeb9 <+9>:     mov    %rsi,%rbx
   0x00007ffff71fbebc <+12>:    sub    $0x18,%rsp
   0x00007ffff71fbec0 <+16>:    cmpb   $0x0,0x337bfa(%rip)        #
0x7ffff7533ac1 <_ZZ25__interceptor_swapcontextE16reported_warning>
   0x00007ffff71fbec7 <+23>:    je     0x7ffff71fbf10
<__interceptor_swapcontext(ucontext_t*, ucontext_t*)+96>
   0x00007ffff71fbec9 <+25>:    lea    0x8(%rsp),%rdx
   0x00007ffff71fbece <+30>:    mov    %rsp,%rsi
   0x00007ffff71fbed1 <+33>:    mov    %rbx,%rdi
   0x00007ffff71fbed4 <+36>:    callq  0x7ffff72ad380
<__asan::ReadContextStack(void*, unsigned long*, unsigned long*)>
   0x00007ffff71fbed9 <+41>:    mov    0x8(%rsp),%rsi
   0x00007ffff71fbede <+46>:    mov    (%rsp),%rdi
   0x00007ffff71fbee2 <+50>:    callq  0x7ffff71fbd10
<ClearShadowMemoryForContextStack(__sanitizer::uptr, __sanitizer::uptr)>
   0x00007ffff71fbee7 <+55>:    mov    %rbx,%rsi
   0x00007ffff71fbeea <+58>:    mov    %rbp,%rdi
   0x00007ffff71fbeed <+61>:    callq  *0x337045(%rip)        # 0x7ffff7532f38
<_ZN14__interception16real_swapcontextE>
ENDBR is missing here.
=> 0x00007ffff71fbef3 <+67>:    mov    0x8(%rsp),%rsi
   0x00007ffff71fbef8 <+72>:    mov    (%rsp),%rdi
   0x00007ffff71fbefc <+76>:    mov    %eax,%ebx
   0x00007ffff71fbefe <+78>:    callq  0x7ffff71fbd10
<ClearShadowMemoryForContextStack(__sanitizer::uptr, __sanitizer::uptr)>
   0x00007ffff71fbf03 <+83>:    add    $0x18,%rsp
   0x00007ffff71fbf07 <+87>:    mov    %ebx,%eax
   0x00007ffff71fbf09 <+89>:    pop    %rbx
   0x00007ffff71fbf0a <+90>:    pop    %rbp
   0x00007ffff71fbf0b <+91>:    retq   
   0x00007ffff71fbf0c <+92>:    nopl   0x0(%rax)
   0x00007ffff71fbf10 <+96>:    lea    0xf27b9(%rip),%rdi        #
0x7ffff72ee6d0
   0x00007ffff71fbf17 <+103>:   xor    %eax,%eax
   0x00007ffff71fbf19 <+105>:   

We need to enhance indirect_return attribute to accept function
pointer:

[hjl@gnu-cfl-1 pr85620]$ cat z.i
struct ucontext;
typedef struct ucontext ucontext_t;

extern int (*swapcontext) (ucontext_t *__restrict __oucp,
                           const ucontext_t *__restrict __ucp)
 __attribute__((__indirect_return__));

extern int res;

void
foo (ucontext_t *oucp, ucontext_t *ucp)
{
  res = swapcontext (oucp, ucp);
}
[hjl@gnu-cfl-1 pr85620]$ make z.s
/export/build/gnu/gcc-8-test/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-8-test/build-x86_64-linux/gcc/ -O2 -fcf-protection -S
z.i
z.i:6:2: warning: \u2018indirect_return\u2019 attribute directive ignored
[-Wattributes]
  __attribute__((__indirect_return__));
  ^~~~~~~~~~~~~
[hjl@gnu-cfl-1 pr85620]$

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]