Bug 74716 - valgrind 2.2.0 makes nptl threaded programs segfault
Bug#: 74716 Product:  Gentoo Linux Version: unspecified Platform: x86
OS/Version: Linux Status: RESOLVED Severity: normal Priority: P2
Resolution: FIXED Assigned To: griffon26@gentoo.org Reported By: pedratan@gmail.com
Component: Development
URL: 
Summary: valgrind 2.2.0 makes nptl threaded programs segfault
Keywords:  
Status Whiteboard: 
Opened: 2004-12-16 19:52 0000
Description:   Opened: 2004-12-16 19:52 0000
When running programs that are linked against /lib/libpthread.so.0, valgrind
uses its compiled libpthread, which results always in:
[some messages]
error while loading shared libraries: libpthread.so.0: cannot enable executable
stack as shared object requires: Invalid argument
[many lines later]
Segmentation fault

Reproducible: Always
Steps to Reproduce:
1. valgrind --tool=memcheck /bin/ls
2.
3.

Actual Results:  
% valgrind --tool=memcheck /bin/ls
==16579== Memcheck, a memory error detector for x86-linux.
==16579== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward et al.
==16579== Using valgrind-2.2.0, a program supervision framework for x86-linux.
==16579== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward et al.
==16579== For more details, rerun with: -v
==16579==
/bin/ls: error while loading shared libraries: libpthread.so.0: cannot enable
executable stack as shared object requires: Invalid argument
==16579== Jump to the invalid address stated on the next line
==16579==    at 0x78E: ???
==16579==    by 0x1B8EF5FE: (within /lib/ld-2.3.4.so)
==16579==    by 0x1B8EF037: (within /lib/ld-2.3.4.so)
==16579==    by 0x1B8E63C5: (within /lib/ld-2.3.4.so)
==16579==  Address 0x78E is not stack'd, malloc'd or (recently) free'd
==16579==
==16579== Process terminating with default action of signal 11 (SIGSEGV)
==16579==  Access not within mapped region at address 0x78E
==16579==    at 0x78E: ???
==16579==    by 0x1B8EF5FE: (within /lib/ld-2.3.4.so)
==16579==    by 0x1B8EF037: (within /lib/ld-2.3.4.so)
==16579==    by 0x1B8E63C5: (within /lib/ld-2.3.4.so)
==16579==
==16579== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
==16579== malloc/free: in use at exit: 0 bytes in 0 blocks.
==16579== malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
==16579== For a detailed leak analysis,  rerun with: --leak-check=yes
==16579== For counts of detected errors, rerun with: -v
Segmentation fault


Expected Results:  
give info about running program

System compiled with USE="nptl nptlonly"
It works in non nptl environments (tested)

CFLAGS="-march=athlon-xp -O2 -pipe -fomit-frame-pointer"

------- Comment #1 From Maurice van der Pot 2004-12-17 16:56:09 0000 -------
Thought this one might interest you, Christian. And any additional information
you may have on this would be appreciated.

------- Comment #2 From Christian Parpart 2004-12-18 07:41:02 0000 -------
interesting, yeah, but able to fix? well.... I gonna take a closer look tonight
on it, too...

thx ;)

------- Comment #3 From Christian Parpart 2004-12-18 07:41:49 0000 -------
ah, btw, you can workaround this by remerging glibc without nptlonly useflag! -
so much for now, cya ;)

------- Comment #4 From Maurice van der Pot 2004-12-19 10:38:44 0000 -------
I added valgrind-2.2.0-r1 that includes a fix.
If it doesn't fix the problem, please reopen this bug.

Thanks for reporting the problem.

------- Comment #5 From Pedro Morales 2004-12-19 12:51:17 0000 -------
Excellent. Thanks a lot.

------- Comment #6 From Alejandro Diaz Caro 2005-02-09 16:48:38 0000 -------
> I added valgrind-2.2.0-r1 that includes a fix.
> If it doesn't fix the problem, please reopen this bug.

Don't work:

$valgrind --tool=memcheck -q --leak-check=yes ./cliente
==379== Conditional jump or move depends on uninitialised value(s)
==379==    at 0x1B8EC9A4: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8E5CE7: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8F23B4: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8E4B43: (within /lib/ld-2.3.4.so)
==379==
==379== Conditional jump or move depends on uninitialised value(s)
==379==    at 0x1B8EC961: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8E5CE7: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8F23B4: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8E4B43: (within /lib/ld-2.3.4.so)
==379==
==379== Conditional jump or move depends on uninitialised value(s)
==379==    at 0x1B8EC82A: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8E5CE7: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8F23B4: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8E4B43: (within /lib/ld-2.3.4.so)
==379==
==379== Conditional jump or move depends on uninitialised value(s)
==379==    at 0x1B8EC832: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8E5CE7: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8F23B4: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8E4B43: (within /lib/ld-2.3.4.so)
==379==
==379== Conditional jump or move depends on uninitialised value(s)
==379==    at 0x1B8EC82A: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8E5D63: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8F23B4: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8E4B43: (within /lib/ld-2.3.4.so)
==379==
==379== Conditional jump or move depends on uninitialised value(s)
==379==    at 0x1B8EC832: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8E5D63: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8F23B4: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8E4B43: (within /lib/ld-2.3.4.so)
==379==
==379== Conditional jump or move depends on uninitialised value(s)
==379==    at 0x1B8EC9A4: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8E5D63: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8F23B4: (within /lib/ld-2.3.4.so)
==379==    by 0x1B8E4B43: (within /lib/ld-2.3.4.so)
==379==
==379== Conditional jump or move depends on uninitialised value(s)
==379==    at 0x1B8EC961: (within /lib/ld-2.3.4.so)
==379==    by 0x4D9C8A09: (within /lib/libc-2.3.4.so)
==379==    by 0x1B8EF0D7: (within /lib/ld-2.3.4.so)
==379==    by 0x4D9C8D46: _dl_open (in /lib/libc-2.3.4.so)
==379==
==379== Conditional jump or move depends on uninitialised value(s)
==379==    at 0x1B8EC9A4: (within /lib/ld-2.3.4.so)
==379==    by 0x4D9C8A09: (within /lib/libc-2.3.4.so)
==379==    by 0x1B8EF0D7: (within /lib/ld-2.3.4.so)
==379==    by 0x4D9C8D46: _dl_open (in /lib/libc-2.3.4.so)
==379==
==379== Conditional jump or move depends on uninitialised value(s)
==379==    at 0x4DA998B2: store_to_database (in /usr/lib/libX11.so.6.2)
==379==    by 0x1BCB53CF: ???
==379==
==379== Conditional jump or move depends on uninitialised value(s)
==379==    at 0x4DA998B8: store_to_database (in /usr/lib/libX11.so.6.2)
==379==    by 0x1BCB53CF: ???
==379==
==379== Conditional jump or move depends on uninitialised value(s)
==379==    at 0x4DA998F2: store_to_database (in /usr/lib/libX11.so.6.2)
==379==    by 0x1BCB53CF: ???
==379==
==379== Conditional jump or move depends on uninitialised value(s)
==379==    at 0x4DA998F8: store_to_database (in /usr/lib/libX11.so.6.2)
==379==    by 0x1BCB53CF: ???
==379==
valgrind: vg_libpthread.c:2334 (open64): Assertion `open64_ptr != ((void *)0) && open64_ptr != open64' failed.

==379== Please report this bug at: valgrind.kde.org


==379==
==379== Invalid free() / delete / delete[]
==379==    at 0x1B9021D0: free (vg_replace_malloc.c:153)
==379==    by 0x4D9D19BB: (within /lib/libc-2.3.4.so)
==379==    by 0x4D9D1579: __libc_freeres (in /lib/libc-2.3.4.so)
==379==    by 0x1B8FBA90: _vgw(float, long double,...)(...)(long double,...)(short) (vg_intercept.c:117)
==379==  Address 0x1B9252D0 is not stack'd, malloc'd or (recently) free'd

emerge info:
Portage 2.0.51-r15 (default-linux/x86/2004.3, gcc-3.3.5, glibc-2.3.4.20040808-r1, 2.6.9-gentoo-r9 i686)
=================================================================
System uname: 2.6.9-gentoo-r9 i686 AMD Duron(tm)
Gentoo Base System version 1.4.16
Python:              dev-lang/python-2.3.4 [2.3.4 (#1, Oct 21 2004, 09:18:58)]
distcc 2.16 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled]
ccache version 2.3 [enabled]
dev-lang/python:     2.3.4
sys-devel/autoconf:  2.59-r6, 2.13
sys-devel/automake:  1.7.9-r1, 1.8.5-r3, 1.5, 1.4_p6, 1.6.3, 1.9.4
sys-devel/binutils:  2.15.92.0.2-r1
sys-devel/libtool:   1.5.10-r4
virtual/os-headers:  2.6.8.1-r1, 2.6.8.1-r2
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CFLAGS="-O2 -march=athlon -pipe -fomit-frame-pointer -funroll-loops"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3.3/env /usr/kde/3.3/share/config /usr/kde/3.3/shutdown /usr/kde/3/share/config /usr/lib/X11/xkb /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-O2 -march=athlon -pipe -fomit-frame-pointer -funroll-loops"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs autoconfig ccache distlocks fixpackages sandbox sfperms"
GENTOO_MIRRORS="http://mirror.datapipe.net/gentoo http://mirror.datapipe.net/gentoo ftp://ftp.gtlib.cc.gatech.edu/pub/gentoo http://open-systems.ufl.edu/mirrors/gentoo"
LANG="es_ES"
LC_ALL="es_ES"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="3dnow 3dnowex X aalib acpi alsa arts audiofile avi bitmap-fonts caps cdparanoia cdr chm crypt cscope cups dga directfb divx4linux doc dvd dvdread encodeesd ethereal f77 fam fbcon fdftk fftw flac flash font-server foomaticdb fortran gd ggi gif ginac gphoto2 gpm gstreamer guile icq imagemagick imap imlib ipv6 jabber java jpeg junit kde lcms ldap libmatroska live mad maildir mbox memlimitmikmod mmx motif mozilla mpeg msn ncurses network nls nocardbus nptl offensiveoggvorbis opengl oscar oss pam pdflib perl pic plotutils png qt quicktime readline real sdl slang snmp speex spell ssl svg svga szip tcltk tetex theora tiff truetype truetype-fonts type1-fonts unicode usb userlocales wmf x86 xine xmms xv xvid yahoo zlib linguas_es"
Unset:  ASFLAGS, CBUILD, CTARGET, LDFLAGS

------- Comment #7 From Maurice van der Pot 2005-02-10 08:57:45 0000 -------
This is a completely different problem. Please open a separate bug report for
it.

Did this problem first occur with -r1? I doubt it.