This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc 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 libc/12123] New: SIGBUS on strstr_sse42 due to bad alignment


http://sourceware.org/bugzilla/show_bug.cgi?id=12123

           Summary: SIGBUS on strstr_sse42 due to bad alignment
           Product: glibc
           Version: 2.12
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: viriketo@gmail.com


I've been having a trouble in the dynamic loader, at some code that ends up
calling strstr(p, "SMP") (the is_system_smp() call, at
__pthread_initialize_minimal_internal), before main(), in a system capable of
sse4.2.

I am using gcc 4.5.1 with glibc 2.12.1 on GNU/Linux i686.

Here is my debugging session, starting the program 'xz' compiled with these
above:

Program received signal SIGSEGV, Segmentation fault.
0xf7f5141e in __strstr_sse42 ()
   from /nix/store/mdjakl9ywywrrz9149cs6n7yfzvb12v7-glibc-2.12.1/lib/libc.so.6
(gdb) bt
#0  0xf7f5141e in __strstr_sse42 ()
   from /nix/store/mdjakl9ywywrrz9149cs6n7yfzvb12v7-glibc-2.12.1/lib/libc.so.6
#1  0xf7fa3af0 in __pthread_initialize_minimal_internal ()
   from
/nix/store/mdjakl9ywywrrz9149cs6n7yfzvb12v7-glibc-2.12.1/lib/libpthread.so.0
#2  0xf7fa3148 in _init ()
   from
/nix/store/mdjakl9ywywrrz9149cs6n7yfzvb12v7-glibc-2.12.1/lib/libpthread.so.0
#3  0xf7fec4d4 in call_init ()
   from
/nix/store/mdjakl9ywywrrz9149cs6n7yfzvb12v7-glibc-2.12.1/lib/ld-linux.so.2
#4  0xf7fec666 in _dl_init_internal ()
   from
/nix/store/mdjakl9ywywrrz9149cs6n7yfzvb12v7-glibc-2.12.1/lib/ld-linux.so.2
#5  0xf7fdd85f in _dl_start_user ()
   from
/nix/store/mdjakl9ywywrrz9149cs6n7yfzvb12v7-glibc-2.12.1/lib/ld-linux.so.2
(gdb) disassemble 
........
0xf7f51416 <__strstr_sse42+70>: call   0xf7f51270 <__m128i_strloadu>
0xf7f5141b <__strstr_sse42+75>: mov    0xc(%ebp),%ecx
0xf7f5141e <__strstr_sse42+78>: movdqa %xmm0,-0x34(%ebp)
0xf7f51423 <__strstr_sse42+83>: cmpb   $0x0,0x1(%ecx)
0xf7f51427 <__strstr_sse42+87>: je     0xf7f51600 <__strstr_sse42+560>
0xf7f5142d <__strstr_sse42+93>: mov    %ecx,%eax
.......


Notice the segfault (SIGBUS in fact) at:
0xf7f5141e <__strstr_sse42+78>: movdqa %xmm0,-0x34(%ebp)

(gdb) print $ebp - 0x34
$4 = (void *) 0xffffce4c

See that the address is not aligned.

The strstr_sse42 code is in ./sysdeps/x86_64/multiarch/strstr.c, and I bet it
is this line (the first __m128i_strloadu call):
  __m128i frag1 = strloadu (p1);

This is a simple assignment. From
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40838 I understand that gcc
supposes that the stack is aligned for every function, and the $ebp here shows
that it is not aligned.

I think the dynamic loader first functions should guarantee an aligned stack,
and it is not the case I think.

If you need more information, the bug is easy to reproduce here.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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