Bug 14359 - tst-cancelx4.out: Segmentation fault
Summary: tst-cancelx4.out: Segmentation fault
Status: RESOLVED INVALID
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.16
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-12 15:30 UTC by wbrana
Modified: 2014-06-17 19:01 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
build log (455.10 KB, application/octet-stream)
2012-07-12 15:30 UTC, wbrana
Details

Note You need to log in before you can comment on or make changes to this bug.
Description wbrana 2012-07-12 15:30:49 UTC
Created attachment 6526 [details]
build log

x86_64-pc-linux-gnu-gcc -m32 tst-cancelx4.c -c -std=gnu99 -fgnu89-inline  -O2 -Wall -Winline -Wwrite-strings -fmerge-all-constants -fno-stack-protector -fno-strict-aliasing -frounding-math -march=core2 -pipe -Wstrict-prototypes   -Wa,-mtune=i686 -fexceptions    -U_FORTIFY_SOURCE -DPIC -U_FORTIFY_SOURCE -DPIC -U_FORTIFY_SOURCE -DPIC  -I../include -I/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl -I/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl -I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../sysdeps/unix/sysv/linux/i386/i686 -I../nptl/sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix/sysv/linux/x86 -I../sysdeps/unix/sysv/linux/x86 -I../sysdeps/unix/sysv/linux/i386/nptl -I../sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../ports/sysdeps/unix/sysv/linux -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/inet -I../nptl/sysdeps/unix/sysv -I../ports/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../nptl/sysdeps/unix -I../ports/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i686/fpu/multiarch -I../sysdeps/i386/i686/fpu -I../sysdeps/i386/i686/multiarch -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -I../sysdeps/i386/i486 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../sysdeps/x86/fpu -I../nptl/sysdeps/i386 -I../sysdeps/i386 -I../sysdeps/x86 -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/generic -I../nptl -I../ports  -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/include -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/include-fixed -isystem /usr/include -D_LIBC_REENTRANT -include ../include/libc-symbols.h   -DNOT_IN_libc=1    -o /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/tst-cancelx4.o -MD -MP -MF /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/tst-cancelx4.o.dt -MT /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/tst-cancelx4.o
x86_64-pc-linux-gnu-gcc -m32 -pie -Wl,-O1 -nostdlib -nostartfiles -o /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/tst-cancelx4  -Wl,-dynamic-linker=/lib32/ld-linux.so.2 -Wl,-O1 -Wl,--hash-style=gnu  -Wl,-z,combreloc -Wl,-z,relro  /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/csu/Scrt1.o /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/csu/crti.o `x86_64-pc-linux-gnu-gcc -m32  --print-file-name=crtbeginS.o` /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/tst-cancelx4.o /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/libpthread.so /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/libpthread_nonshared.a  -Wl,-rpath-link=/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/math:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/elf:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/dlfcn:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nss:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nis:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/rt:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/resolv:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/crypt:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/libc.so.6 /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/libc_nonshared.a -Wl,--as-needed /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/elf/ld.so -Wl,--no-as-needed -lgcc -Wl,--as-needed -lgcc_s  -Wl,--no-as-needed `x86_64-pc-linux-gnu-gcc -m32  --print-file-name=crtendS.o` /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/csu/crtn.o
GCONV_PATH=/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/iconvdata LC_ALL=C   /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/elf/ld-linux.so.2 --library-path /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/math:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/elf:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/dlfcn:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nss:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nis:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/rt:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/resolv:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/crypt:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/tst-cancelx4  > /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/tst-cancelx4.out
Didn't expect signal from child: got `Segmentation fault'
make[2]: *** [/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/tst-cancelx4.out] Error 1

x86_64-pc-linux-gnu

/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/glibc-2.16.0/configure --enable-stackguard-randomization --enable-add-ons=nptl,c_stubs,libidn,ports --enable-kernel=2.6.16 --without-selinux --without-cvs --enable-bind-now --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --disable-profile --without-gd --with-headers=/usr/include --prefix=/usr --libdir=/usr/lib32 --mandir=/usr/share/man --infodir=/usr/share/info --libexecdir=/usr/lib32/misc/glibc --enable-obsolete-rpc --disable-systemtap

/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/glibc-2.16.0/configure --enable-stackguard-randomization --enable-add-ons=nptl,c_stubs,libidn,ports --enable-kernel=2.6.16 --without-selinux --without-cvs --enable-bind-now --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --disable-profile --without-gd --with-headers=/usr/include --prefix=/usr --libdir=/usr/lib64 --mandir=/usr/share/man --infodir=/usr/share/info --libexecdir=/usr/lib64/misc/glibc --enable-obsolete-rpc --disable-systemtap

Linux localhost 3.4.4-hardened-r2 #1 SMP Thu Jul 12 11:44:22 CEST 2012 x86_64 Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz GenuineIntel GNU/Linux

Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.4/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.4/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /mnt/md3/cache/portage/sys-devel/gcc-4.5.4/work/gcc-4.5.4/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.4 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.4 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.4/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.4/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --without-ppl --without-cloog --disable-lto --disable-nls --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp --enable-esp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.5.4/python --enable-checking=release --disable-libgcj --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo Hardened 4.5.4 p1.5, pie-0.4.7'
Thread model: posix
gcc version 4.5.4 (Gentoo Hardened 4.5.4 p1.5, pie-0.4.7) 

GNU ld (GNU Binutils) 2.22
Comment 1 jsm-csl@polyomino.org.uk 2012-07-12 16:23:54 UTC
Could you run the test without the output redirection and post the output 
to tst-cancelx4.out, so we can see the exact point at which it segfaults?
Comment 2 jsm-csl@polyomino.org.uk 2012-07-12 16:27:51 UTC
Sorry, that was mangled.  Could you run the test without the output 
redirection to tst-cancelx4.out and post the output?  (The contents of 
tst-cancelx4.out *might* be helpful, but running without redirection may 
avoid issues with stdio buffering and so make it more likely that the 
point at which the output ends is actually the point at which the test 
crashed.)
Comment 3 wbrana 2012-07-12 16:59:31 UTC
in-time cancel test of 'read' successful
in-time cancel test of 'readv' successful
in-time cancel test of 'select' successful
in-time cancel test of 'pselect' successful
in-time cancel test of 'poll' successful
in-time cancel test of 'ppoll' successful
in-time cancel test of 'write' successful
in-time cancel test of 'writev' successful
in-time cancel test of 'sleep' successful
Didn't expect signal from child: got `Segmentation fault'

I can't get useful data from gdb.

[pid 17006] write(1, "in-time cancel test of 'sleep' s"..., 42in-time cancel test of 'sleep' successful
) = 42
[pid 17006] clone(Process 17016 attached
 <unfinished ...>
[pid 17016] set_robust_list(0xffffffffed4bbbb0, 12) = 0
[pid 17006] <... clone resumed> child_stack=0xffffffffed4bb464, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0xffffffffed4bbba8, tls=0xffffffffed4bbba8, child_tidptr=0xfffffffff6edce30) = 17016
[pid 17016] futex(0xffffffffed6ad06c, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 17006] futex(0xffffffffed6ad06c, FUTEX_WAKE_PRIVATE, 2147483647 <unfinished ...>
[pid 17016] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavailable)
[pid 17006] <... futex resumed> )       = 0
[pid 17016] nanosleep({4294, 967295000},  <unfinished ...>
[pid 17006] nanosleep({0, 100000000}, 0xfffffffff6edcf18) = 0
[pid 17006] tgkill(17006, 17016, SIGRTMIN <unfinished ...>
[pid 17016] <... nanosleep resumed> NULL) = ? ERESTART_RESTARTBLOCK (Interrupted by signal)
[pid 17006] <... tgkill resumed> )      = 0
[pid 17016] --- SIGRTMIN {si_signo=SIGRTMIN, si_code=SI_TKILL, si_pid=17006, si_uid=250} ---
[pid 17006] futex(0xffffffffed4bbba8, FUTEX_WAIT, 17016, NULL <unfinished ...>
[pid 17016] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x174} ---
[pid 17016] +++ killed by SIGSEGV +++
[pid 17006] +++ killed by SIGSEGV +++
<... waitpid resumed> [{WIFSIGNALED(s) && WTERMSIG(s) == SIGSEGV}], 0) = 17006
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=17006, si_status=SIGSEGV, si_utime=0, si_stime=0} ---
futex(0xffffffffed6858e0, FUTEX_WAKE_PRIVATE, 2147483647) = 0
write(2, "Didn't expect signal from child:"..., 58Didn't expect signal from child: got `Segmentation fault'
) = 58
Comment 4 Andreas Schwab 2012-07-12 17:04:45 UTC
Running the test with --direct will skip the fork.
Comment 5 wbrana 2012-07-12 17:16:42 UTC
with --direct:

gdb hangs with this outout:

Error while mapping shared library sections:
linux-gate.so.1: Permission denied.
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
[New LWP 17576]

strace:
 
[pid 17560] +++ exited with 0 +++
<... futex resumed> )                   = 0
write(1, "in-time cancel test of 'sleep' s"..., 42in-time cancel test of 'sleep' successful
) = 42
clone(Process 17561 attached
 <unfinished ...>
[pid 17561] set_robust_list(0xfffffffff0e56bb0, 12) = 0
[pid 17551] <... clone resumed> child_stack=0xfffffffff0e56464, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0xfffffffff0e56ba8, tls=0xfffffffff0e56ba8, child_tidptr=0xfffffffffe8329b0) = 17561
[pid 17561] futex(0xfffffffff104806c, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 17551] futex(0xfffffffff104806c, FUTEX_WAKE_PRIVATE, 2147483647 <unfinished ...>
[pid 17561] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavailable)
[pid 17551] <... futex resumed> )       = 0
[pid 17561] nanosleep({4294, 967295000},  <unfinished ...>
[pid 17551] nanosleep({0, 100000000}, 0xfffffffffe832a98) = 0
[pid 17551] tgkill(17551, 17561, SIGRTMIN <unfinished ...>
[pid 17561] <... nanosleep resumed> NULL) = ? ERESTART_RESTARTBLOCK (Interrupted by signal)
[pid 17551] <... tgkill resumed> )      = 0
[pid 17561] --- SIGRTMIN {si_signo=SIGRTMIN, si_code=SI_TKILL, si_pid=17551, si_uid=250} ---
[pid 17551] futex(0xfffffffff0e56ba8, FUTEX_WAIT, 17561, NULL <unfinished ...>
[pid 17561] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x174} ---
[pid 17561] +++ killed by SIGSEGV +++
+++ killed by SIGSEGV +++
Comment 6 wbrana 2012-07-12 17:41:15 UTC
I have got some backtrace, but /lib32/libc.so.6 is glibc 2.14.1

Core was generated by `./tst-cancelx4 --direct'.
Program terminated with signal 11, Segmentation fault.
#0  0x0a0daa80 in _Unwind_Resume@plt ()
(gdb) bt
#0  0x0a0daa80 in _Unwind_Resume@plt ()
#1  0x0a0de6ed in tf_usleep ()
#2  0xdfe6ed93 in start_thread () from /lib32/libpthread.so.0
#3  0xdfde04ee in clone () from /lib32/libc.so.6
Comment 7 Andreas Schwab 2012-07-13 08:05:33 UTC
You need to run it via testrun.sh to pick up the uninstalled library from the build directory.
Comment 8 wbrana 2012-07-13 08:15:59 UTC
gdb hangs or gives no useful info in that case
Comment 9 wbrana 2012-07-13 11:03:46 UTC
It seems to crash in this function

00005610 <tf_usleep>:
    5610:       55                      push   %ebp
    5611:       89 e5                   mov    %esp,%ebp
    5613:       83 ec 18                sub    $0x18,%esp
    5616:       89 5d f8                mov    %ebx,-0x8(%ebp)
    5619:       89 75 fc                mov    %esi,-0x4(%ebp)
    561c:       e8 00 00 00 00          call   5621 <tf_usleep+0x11>
    5621:       5b                      pop    %ebx
    5622:       81 c3 17 48 00 00       add    $0x4817,%ebx
    5628:       8d b3 34 02 00 00       lea    0x234(%ebx),%esi
    562e:       89 34 24                mov    %esi,(%esp)
    5631:       e8 4a bf ff ff          call   1580 <pthread_barrier_wait@plt>
    5636:       40                      inc    %eax
    5637:       83 f8 01                cmp    $0x1,%eax
    563a:       76 24                   jbe    5660 <tf_usleep+0x50>
    563c:       8d 83 ea d1 ff ff       lea    -0x2e16(%ebx),%eax
    5642:       89 44 24 04             mov    %eax,0x4(%esp)
    5646:       8d 83 04 cc ff ff       lea    -0x33fc(%ebx),%eax
    564c:       89 04 24                mov    %eax,(%esp)
    564f:       e8 bc be ff ff          call   1510 <printf@plt>
    5654:       c7 04 24 01 00 00 00    movl   $0x1,(%esp)
    565b:       e8 30 c1 ff ff          call   1790 <exit@plt>
    5660:       8b 55 08                mov    0x8(%ebp),%edx
    5663:       85 d2                   test   %edx,%edx
    5665:       74 69                   je     56d0 <tf_usleep+0xc0>
    5667:       89 34 24                mov    %esi,(%esp)
    566a:       e8 11 bf ff ff          call   1580 <pthread_barrier_wait@plt>
    566f:       40                      inc    %eax
    5670:       83 f8 01                cmp    $0x1,%eax
    5673:       76 2b                   jbe    56a0 <tf_usleep+0x90>
    5675:       8d 83 ea d1 ff ff       lea    -0x2e16(%ebx),%eax
    567b:       89 44 24 04             mov    %eax,0x4(%esp)
    567f:       8d 83 f0 cc ff ff       lea    -0x3310(%ebx),%eax
    5685:       89 04 24                mov    %eax,(%esp)
    5688:       e8 83 be ff ff          call   1510 <printf@plt>
    568d:       c7 04 24 01 00 00 00    movl   $0x1,(%esp)                                                                       
    5694:       e8 f7 c0 ff ff          call   1790 <exit@plt>                                                                   
    5699:       8d b4 26 00 00 00 00    lea    0x0(%esi,%eiz,1),%esi                                                             
    56a0:       31 c0                   xor    %eax,%eax                                                                         
    56a2:       89 04 24                mov    %eax,(%esp)                                                                       
    56a5:       e8 26 c0 ff ff          call   16d0 <usleep@plt>                                                                 
    56aa:       8d 83 ea d1 ff ff       lea    -0x2e16(%ebx),%eax                                                                
    56b0:       89 44 24 04             mov    %eax,0x4(%esp)                                                                    
    56b4:       8d 83 96 cf ff ff       lea    -0x306a(%ebx),%eax                                                                
    56ba:       89 04 24                mov    %eax,(%esp)                                                                       
    56bd:       e8 4e be ff ff          call   1510 <printf@plt>                                                                 
    56c2:       c7 04 24 01 00 00 00    movl   $0x1,(%esp)                                                                       
    56c9:       e8 c2 c0 ff ff          call   1790 <exit@plt>                                                                   
    56ce:       66 90                   xchg   %ax,%ax
    56d0:       b8 ff ff ff ff          mov    $0xffffffff,%eax
    56d5:       eb cb                   jmp    56a2 <tf_usleep+0x92>
    56d7:       89 c6                   mov    %eax,%esi
    56d9:       c7 04 24 00 00 00 00    movl   $0x0,(%esp)
    56e0:       e8 1b c5 ff ff          call   1c00 <cl>
    56e5:       89 34 24                mov    %esi,(%esp)
    56e8:       e8 93 c3 ff ff          call   1a80 <_Unwind_Resume@plt>
    56ed:       8d 76 00                lea    0x0(%esi),%esi
Comment 10 wbrana 2012-07-13 11:07:07 UTC
 ldd ./tst-cancelx4 
	linux-gate.so.1 =>  (0xe8cb4000)
	libpthread.so.0 => /lib32/libpthread.so.0 (0xe8c5a000)
	libc.so.6 => /lib32/libc.so.6 (0xe8afd000)
	libgcc_s.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.1/32/libgcc_s.so.1 (0xe8ae1000)
	/lib32/ld-linux.so.2 (0xe8c97000)
Comment 11 wbrana 2012-07-14 09:07:50 UTC
==22761== Thread 2:
==22761== Invalid read of size 4
==22761==    at 0x109AC0: ??? (in /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/tst-cancelx4)
==22761==    by 0x493F4ED: clone (in /lib32/libc-2.14.1.so)
==22761==  Address 0x170 is not stack'd, malloc'd or (recently) free'd
==22761== 
==22761== 
==22761== Process terminating with default action of signal 11 (SIGSEGV)
==22761==  Access not within mapped region at address 0x170
==22761==    at 0x109AC0: ??? (in /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/tst-cancelx4)
==22761==    by 0x493F4ED: clone (in /lib32/libc-2.14.1.so)
==22761==  If you believe this happened as a result of a stack
==22761==  overflow in your program's main thread (unlikely but
==22761==  possible), you can try to increase the size of the
==22761==  main thread stack using the --main-stacksize= flag.
==22761==  The main thread stack size used in this run was 8388608.
Comment 12 jsm-csl@polyomino.org.uk 2012-07-14 20:20:14 UTC
On Sat, 14 Jul 2012, wbrana at gmail dot com wrote:

> ==22761==    by 0x493F4ED: clone (in /lib32/libc-2.14.1.so)

If there are references like that to system libraries, the test is not 
being built or run correctly.  Either run it with the exact (very long) 
command, including environment settings, that the testsuite itself uses, 
or else rebuild the test with -Wl,-dynamic-linker and -Wl,-rpath options 
pointing to the appropriate places in the install_root directory you 
specified when installing the newly built library.
Comment 13 wbrana 2012-07-14 20:28:23 UTC
If I run test with command
 ./testrun.sh nptl/tst-cancelx4 --direct
I'm getting useless back trace

Core was generated by `./elf/ld-linux.so.2 --library-path .:./math:./elf:./dlfcn:./nss:./nis:./rt:./re'.
Program terminated with signal 11, Segmentation fault.
#0  0xe7263ac0 in ?? ()
(gdb) bt full
#0  0xe7263ac0 in ?? ()
No symbol table info available.
#1  0xe72655a7 in ?? ()
No symbol table info available.
#2  0xe705ed90 in ?? ()
No symbol table info available.
#3  0xe718cfce in ?? ()
No symbol table info available.
Comment 14 jsm-csl@polyomino.org.uk 2012-07-14 20:33:27 UTC
On Sat, 14 Jul 2012, wbrana at gmail dot com wrote:

> If I run test with command
>  ./testrun.sh nptl/tst-cancelx4 --direct
> I'm getting useless back trace

Better backtracing is certainly one reason to rebuild the test with 
appropriate -dynamic-linker and -rpath options (given that you've 
installed the library somewhere) so that it can be run directly rather 
than via the dynamic linker.
Comment 15 wbrana 2012-07-14 20:38:19 UTC
How it can be done?
Comment 16 wbrana 2012-07-14 20:38:19 UTC
How it can be done?
Comment 17 Andreas Schwab 2012-07-14 21:10:51 UTC
$ cat configparms
ifdef LT
config-LDFLAGS = -Wl,-dynamic-linker=$(elf-objpfx)$(rtld-installed-name) \
                 -Wl,-rpath=$(rpath-link)$(patsubst %,:%,$(sysdep-library-path))
endif
$ rm nptl/tst-cancelx4
$ make nptl/tests LT=1
Comment 18 wbrana 2012-07-14 21:27:45 UTC
build fails

make nptl/tests LT=1
make -r PARALLELMFLAGS="" -C /mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/glibc-2.16.0 objdir=`pwd` nptl/tests
make[1]: Entering directory `/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/glibc-2.16.0'
make  subdir=nptl -C nptl ..=../ tests
make[2]: Entering directory `/mnt/md3/cache/portage/sys-libs/glibc-2.16.0/work/glibc-2.16.0/nptl'
ln -f /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/crti.o /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/32/crti.o
ln -f /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/crtn.o /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/32/crtn.o
diff -p -U 0 ../sysdeps/unix/sysv/linux/i386/nptl/libpthread.abilist /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/libpthread.symlist
g++ tst-cancel24.cc -c  -O2 -Wall -Winline -Wwrite-strings -fmerge-all-constants -fno-stack-protector -fno-strict-aliasing -frounding-math -march=core2 -pipe   -Wa,-mtune=i686    -U_FORTIFY_SOURCE -DPIC -U_FORTIFY_SOURCE -DPIC -U_FORTIFY_SOURCE -DPIC  -I../include -I/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl -I/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl -I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../sysdeps/unix/sysv/linux/i386/i686 -I../nptl/sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix/sysv/linux/x86 -I../sysdeps/unix/sysv/linux/x86 -I../sysdeps/unix/sysv/linux/i386/nptl -I../sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../ports/sysdeps/unix/sysv/linux -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/inet -I../nptl/sysdeps/unix/sysv -I../ports/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../nptl/sysdeps/unix -I../ports/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i686/fpu/multiarch -I../sysdeps/i386/i686/fpu -I../sysdeps/i386/i686/multiarch -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -I../sysdeps/i386/i486 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../sysdeps/x86/fpu -I../nptl/sysdeps/i386 -I../sysdeps/i386 -I../sysdeps/x86 -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/generic -I../nptl -I../ports  -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/include -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/include-fixed -isystem /usr/include -D_LIBC_REENTRANT -include ../include/libc-symbols.h   -DNOT_IN_libc=1    -o /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/tst-cancel24.o -MD -MP -MF /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/tst-cancel24.o.dt -MT /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/tst-cancel24.o
In file included from ../nptl/sysdeps/pthread/pthread.h:24:0,
                 from ../include/pthread.h:1,
                 from tst-cancel24.cc:1:
../include/time.h:51:14: warning: 'stdcall' attribute ignored
../include/time.h:102:6: warning: 'stdcall' attribute ignored
In file included from tst-cancel24.cc:4:0:
../include/stdio.h:97:37: warning: 'stdcall' attribute ignored
x86_64-pc-linux-gnu-gcc -m32 -pie -Wl,-O1 -nostdlib -nostartfiles -o /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/tst-cancel24  -Wl,-dynamic-linker=/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/elf/ld-linux.so.2 -Wl,-rpath=/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/math:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/elf:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/dlfcn:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nss:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nis:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/rt:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/resolv:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/crypt:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl  -Wl,--no-as-needed -lstdc++ -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/csu/Scrt1.o /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/csu/crti.o `x86_64-pc-linux-gnu-gcc -m32  --print-file-name=crtbeginS.o` /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/tst-cancel24.o /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/libpthread.so /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/libpthread_nonshared.a  -Wl,-rpath-link=/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/math:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/elf:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/dlfcn:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nss:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nis:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/rt:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/resolv:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/crypt:/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/libc.so.6 /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/libc_nonshared.a -Wl,--as-needed /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/elf/ld.so -Wl,--no-as-needed -lgcc -Wl,--as-needed -lgcc_s  -Wl,--no-as-needed `x86_64-pc-linux-gnu-gcc -m32  --print-file-name=crtendS.o` /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/csu/crtn.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/../../../../x86_64-pc-linux-gnu/bin/ld: i386:x86-64 architecture of input file `/mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/tst-cancel24.o' is incompatible with i386 output
collect2: ld returned 1 exit status
Comment 19 wbrana 2012-07-14 21:43:35 UTC
managed to compile it after fixing config.make:

Core was generated by `./tst-cancelx4 --direct'.
Program terminated with signal 11, Segmentation fault.
#0  0x0a6d23a0 in _Unwind_Resume@plt ()
(gdb) bt full
#0  0x0a6d23a0 in _Unwind_Resume@plt ()
No symbol table info available.
#1  0x0a6d600d in tf_usleep ()
No symbol table info available.
#2  0xea186368 in start_thread () from /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/libpthread.so.0
No symbol table info available.
#3  0xea0dee1e in clone () from /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/libc.so.6
No symbol table info available.


==11864== Thread 2:
==11864== Invalid read of size 4
==11864==    at 0x10A3A0: ??? (in /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/tst-cancelx4)
==11864==    by 0x4836367: start_thread (in /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/libpthread.so)
==11864==    by 0x4937E1D: clone (in /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/libc.so)
==11864==  Address 0x174 is not stack'd, malloc'd or (recently) free'd
==11864== 
==11864== 
==11864== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==11864==  Access not within mapped region at address 0x174
==11864==    at 0x10A3A0: ??? (in /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/tst-cancelx4)
==11864==    by 0x4836367: start_thread (in /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/nptl/libpthread.so)
==11864==    by 0x4937E1D: clone (in /mnt/md3/cache/portage/sys-libs/glibc-2.16.0.bak/work/build-x86-x86_64-pc-linux-gnu-nptl/libc.so)
Comment 20 wbrana 2012-07-15 12:26:32 UTC
compiled with -ggdb, no useful output from Valgrind 


Core was generated by `./tst-cancelx4 --direct'.
Program terminated with signal 11, Segmentation fault.
#0  0x0ed0c370 in _Unwind_Resume@plt ()
(gdb) bt full
#0  0x0ed0c370 in _Unwind_Resume@plt ()
No symbol table info available.
#1  0x0ed0ffdd in __pthread_cleanup_routine (__frame=<optimized out>) at ../nptl/sysdeps/pthread/pthread.h:602
No locals.
#2  tf_usleep (arg=0x0) at tst-cancel4.c:335
        r = <optimized out>
        __FUNCTION__ = "tf_usleep"
#3  0xe062c2d8 in start_thread (arg=0xe0455b40) at pthread_create.c:308
        pd = 0xe0455b40
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {-530334048, 0, 4001536, -532327320, 1171377040, 183737232}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
        robust = <optimized out>
        pagesize_m1 = <optimized out>
        sp = <optimized out>
        freesize = <optimized out>
        __PRETTY_FUNCTION__ = "start_thread"
#4  0xe05872ee in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:132
No locals.
Comment 21 wbrana 2012-07-15 13:26:44 UTC
(gdb) bt
#0  0x0ed0c370 in _Unwind_Resume@plt ()
#1  0x0ed0ffdd in __pthread_cleanup_routine (__frame=<optimized out>) at ../nptl/sysdeps/pthread/pthread.h:602
#2  tf_usleep (arg=0x0) at tst-cancel4.c:335
#3  0xe062c2d8 in start_thread (arg=0xe0455b40) at pthread_create.c:308
#4  0xe05872ee in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:132
(gdb) disas /r 0x0ed0c370
Dump of assembler code for function _Unwind_Resume@plt:
=> 0x0ed0c370 <+0>:	ff a3 74 01 00 00	jmp    *0x174(%ebx)
   0x0ed0c376 <+6>:	68 d0 02 00 00	push   $0x2d0
   0x0ed0c37b <+11>:	e9 40 fa ff ff	jmp    0xed0bdc0
End of assembler dump.
(gdb) info registers
eax            0xe0455d90	-532324976
ecx            0xed13e30	248593968
edx            0x0	0
ebx            0x0	0
esp            0xe045534c	0xe045534c
ebp            0xe0455368	0xe0455368
esi            0xe0455d90	-532324976
edi            0x3d0f00	4001536
eip            0xed0c370	0xed0c370 <_Unwind_Resume@plt>
eflags         0x10202	[ IF RF ]
cs             0x23	35
ss             0x2b	43
ds             0x2b	43
es             0x2b	43
fs             0x0	0
gs             0x63	99
Comment 22 Carlos O'Donell 2012-07-24 02:34:59 UTC
(In reply to comment #21)
> (gdb) bt
> #0  0x0ed0c370 in _Unwind_Resume@plt ()
> #1  0x0ed0ffdd in __pthread_cleanup_routine (__frame=<optimized out>) at
> ../nptl/sysdeps/pthread/pthread.h:602
> #2  tf_usleep (arg=0x0) at tst-cancel4.c:335
> #3  0xe062c2d8 in start_thread (arg=0xe0455b40) at pthread_create.c:308
> #4  0xe05872ee in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:132
> (gdb) disas /r 0x0ed0c370
> Dump of assembler code for function _Unwind_Resume@plt:
> => 0x0ed0c370 <+0>:    ff a3 74 01 00 00    jmp    *0x174(%ebx)
>    0x0ed0c376 <+6>:    68 d0 02 00 00    push   $0x2d0
>    0x0ed0c37b <+11>:    e9 40 fa ff ff    jmp    0xed0bdc0
> End of assembler dump.
> (gdb) info registers
> eax            0xe0455d90    -532324976
> ecx            0xed13e30    248593968
> edx            0x0    0
> ebx            0x0    0
> esp            0xe045534c    0xe045534c
> ebp            0xe0455368    0xe0455368
> esi            0xe0455d90    -532324976
> edi            0x3d0f00    4001536
> eip            0xed0c370    0xed0c370 <_Unwind_Resume@plt>
> eflags         0x10202    [ IF RF ]
> cs             0x23    35
> ss             0x2b    43
> ds             0x2b    43
> es             0x2b    43
> fs             0x0    0
> gs             0x63    99

This is tricky. It could be a miscompilation of either glibc or the testcase by the compiler which causes the unwinder to fail.

When you run the testsuite for glibc what are the results?

The official 2.16 release had a clean testsuite run:
http://sourceware.org/glibc/wiki/Release/2.16

The reason I ask is that other failures in the testsuite might indicate a problem with your build environment.
Comment 23 wbrana 2012-07-24 07:30:51 UTC
there are many test failures, see attached build log
Comment 24 Carlos O'Donell 2012-07-24 13:21:52 UTC
(In reply to comment #23)
> there are many test failures, see attached build log

You are applying Gentoo specific patches to glibc, and that makes it difficult for us to help you. If you were doing a vanilla glibc build, and your test results were clean with the exception of tst-cancelx4, then we could help. As it stands you have over 45 errors with the testsuite. Something is wrong with either your compiler, linker, assembler, or dependent libraries.

The best thing you can do now is to go back to Gentoo and seek help with their maintainers to determine why you have so many failures building glibc for that distribution.

We aren't gentoo experts and we don't know or understand the patches you are applying. Given that I'm closing this issue as resolved and invalid, not because we don't want to help, but because we don't have the required experience to help you. If you are building a modified glibc in gentoo please seek help with gentoo first and work on reducing your testsuite failures.