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

--- Comment #5 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Uroš Bizjak from comment #4)

> Program received signal SIGSEGV, Segmentation fault.
> 0xf7e24064 in __run_exit_handlers (status=1, listp=0xf7fca3fc
> <__exit_funcs>, run_list_atexit=true, run_dtors=true)
>     at exit.c:114
> warning: Source file is more recent than executable.
> 114               if (__glibc_unlikely (new_exitfn_called !=
> __new_exitfn_called))
> 
> (gdb) list
> 109                   break;
> 110                 }
> 111               /* Re-lock again before looking at global state.  */
> 112               __libc_lock_lock (__exit_funcs_lock);
> 113
> 114               if (__glibc_unlikely (new_exitfn_called !=
> __new_exitfn_called))
> 115                 /* The last exit function, or another thread, has
> registered
> 116                    more exit functions.  Start the loop over.  */
> 117                 goto restart;
> 118             }

Here is what happens:

   0xf7e2405c <+188>:   movq   0x3720(%ebp),%xmm0
2> 0xf7e24064 <+196>:   movdqa (%esp),%xmm1
   0xf7e24069 <+201>:   pxor   %xmm0,%xmm1
   0xf7e2406d <+205>:   movdqa %xmm1,%xmm0
   0xf7e24071 <+209>:   movd   %xmm0,%ecx
   0xf7e24075 <+213>:   psrlq  $0x20,%xmm0
   0xf7e2407a <+218>:   movd   %xmm0,%eax
   0xf7e2407e <+222>:   or     %ecx,%eax
   0xf7e24080 <+224>:   jne    0xf7e23ffe <__run_exit_handlers+94>
   0xf7e24086 <+230>:   mov    0x4(%edi),%ecx
   0xf7e24089 <+233>:   test   %ecx,%ecx
   0xf7e2408b <+235>:   je     0xf7e24110 <__run_exit_handlers+368>
   0xf7e24091 <+241>:   lea    -0x1(%ecx),%eax
   0xf7e24094 <+244>:   mov    0x3724(%ebp),%edx
   0xf7e2409a <+250>:   mov    %eax,0x4(%edi)
   0xf7e2409d <+253>:   mov    0x3720(%ebp),%eax
1> 0xf7e240a3 <+259>:   mov    %edx,0x4(%esp)
   0xf7e240a7 <+263>:   mov    %eax,(%esp)

At 1>, new_exitfn_called is copied from __new_exitfn_called to a stack
location. At point 2>, the (unaligned) location is accessed with full 128 bit
movdqa access (which seems wrong, probably movq should be emitted here).

Please provide a preprocessed source of exit.c (the file is called exit.i and
can be generated by adding --save-temps to the compile command that compiled
exit.c) from the build and the exact compile flags that produce the above
assembly.

Reply via email to