Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 32966 - Valgrind doesnt work with NPTL pthread implementation
Summary: Valgrind doesnt work with NPTL pthread implementation
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: Caleb Tennis (RETIRED)
URL: http://bugs.kde.org/show_bug.cgi?id=6...
Whiteboard:
Keywords:
: 43305 56622 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-11-07 13:16 UTC by Jan Killius
Modified: 2004-07-24 22:36 UTC (History)
11 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Diff to make valgrind-2.1.0 compile against nptl version of pthreadtypes.h (nptl.diff,38.55 KB, patch)
2004-02-11 07:50 UTC, Sami Nieminen
Details | Diff
1 of 3 part patch (2.1tocvs-1.patch,1.05 MB, patch)
2004-02-11 21:26 UTC, Christopher Rude
Details | Diff
part 2 of 3 (2.1tocvs-2.patch,1.54 MB, patch)
2004-02-11 21:29 UTC, Christopher Rude
Details | Diff
part 3 of 3 (postcvs-nptl.patch,38.92 KB, patch)
2004-02-11 21:31 UTC, Christopher Rude
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Killius 2003-11-07 13:16:32 UTC
If i try to emerge valgrind, I get the following error: 
gcc -DHAVE_CONFIG_H -I. -I. -I..  -I./demangle -I../include -DVG_LIBDIR="\"/usr/
lib"\"   -Winline -Wall -Wshadow -O -fomit-frame-pointer 
-mpreferred-stack-boundary=2 -g -mpreferred-stack-boundary=2 -c `test -f 
'vg_scheduler.c' || echo './'`vg_scheduler.c 
vg_scheduler.c: In function `release_one_thread_waiting_on_mutex': 
vg_scheduler.c:2340: error: union has no member named `__m_owner' 
vg_scheduler.c:2345: error: union has no member named `__m_count' 
vg_scheduler.c:2346: error: union has no member named `__m_owner' 
vg_scheduler.c:2352: error: union has no member named `__m_owner' 
vg_scheduler.c:2352: error: `_pthread_descr' undeclared (first use in this 
function) 
vg_scheduler.c:2352: error: (Each undeclared identifier is reported only once 
vg_scheduler.c:2352: error: for each function it appears in.) 
vg_scheduler.c:2352: error: syntax error before "i" 
vg_scheduler.c: In function `do_pthread_mutex_lock': 
vg_scheduler.c:2396: error: union has no member named `__m_kind' 
vg_scheduler.c:2406: error: union has no member named `__m_count' 
vg_scheduler.c:2415: error: union has no member named `__m_count' 
vg_scheduler.c:2417: error: union has no member named `__m_owner' 
vg_scheduler.c:2420: error: union has no member named `__m_owner' 
vg_scheduler.c:2422: error: union has no member named `__m_kind' 
vg_scheduler.c:2424: error: union has no member named `__m_count' 
vg_scheduler.c:2428: error: union has no member named `__m_count' 
vg_scheduler.c:2461: error: union has no member named `__m_owner' 
vg_scheduler.c:2466: error: union has no member named `__m_count' 
vg_scheduler.c:2467: error: union has no member named `__m_owner' 
vg_scheduler.c:2467: error: `_pthread_descr' undeclared (first use in this 
function) 
vg_scheduler.c:2467: error: syntax error before "tid" 
vg_scheduler.c: In function `do_pthread_mutex_unlock': 
vg_scheduler.c:2501: error: union has no member named `__m_kind' 
vg_scheduler.c:2502: error: union has no member named `__m_kind' 
vg_scheduler.c:2503: error: union has no member named `__m_owner' 
vg_scheduler.c:2504: error: union has no member named `__m_owner' 
vg_scheduler.c:2508: error: union has no member named `__m_kind' 
vg_scheduler.c:2518: error: union has no member named `__m_count' 
vg_scheduler.c:2528: error: union has no member named `__m_count' 
vg_scheduler.c:2536: error: union has no member named `__m_owner' 
vg_scheduler.c:2546: error: union has no member named `__m_count' 
vg_scheduler.c:2547: error: union has no member named `__m_kind' 
vg_scheduler.c:2548: error: union has no member named `__m_count' 
vg_scheduler.c:2555: error: union has no member named `__m_count' 
vg_scheduler.c:2556: error: union has no member named `__m_owner' 
vg_scheduler.c: In function `do_pthread_cond_timedwait_TIMEOUT': 
vg_scheduler.c:2610: error: union has no member named `__m_owner' 
vg_scheduler.c:2612: error: union has no member named `__m_count' 
vg_scheduler.c:2617: error: union has no member named `__m_owner' 
vg_scheduler.c:2617: error: `_pthread_descr' undeclared (first use in this 
function) 
vg_scheduler.c:2617: error: syntax error before "tid" 
vg_scheduler.c:2618: error: union has no member named `__m_count' 
vg_scheduler.c:2630: error: union has no member named `__m_count' 
vg_scheduler.c: In function `release_N_threads_waiting_on_cond': 
vg_scheduler.c:2681: error: union has no member named `__m_owner' 
vg_scheduler.c:2683: error: union has no member named `__m_count' 
vg_scheduler.c:2687: error: union has no member named `__m_owner' 
vg_scheduler.c:2687: error: `_pthread_descr' undeclared (first use in this 
function) 
vg_scheduler.c:2687: error: syntax error before "i" 
vg_scheduler.c:2688: error: union has no member named `__m_count' 
vg_scheduler.c:2701: error: union has no member named `__m_count' 
vg_scheduler.c: In function `do_pthread_cond_wait': 
vg_scheduler.c:2750: error: union has no member named `__m_kind' 
vg_scheduler.c:2760: error: union has no member named `__m_count' 
vg_scheduler.c:2770: error: union has no member named `__m_count' 
vg_scheduler.c:2771: error: union has no member named `__m_owner' 
vg_scheduler.c: In function `scheduler_sanity': 
vg_scheduler.c:3570: error: union has no member named `__m_count' 
vg_scheduler.c:3571: error: union has no member named `__m_owner' 
vg_scheduler.c:3572: error: union has no member named `__m_owner' 
make[3]: *** [vg_scheduler.o] Error 1 
make[3]: Leaving directory `/var/tmp/portage/valgrind-2.0_pre20031012/work/
valgrind-20031012/coregrind' 
make[2]: *** [all-recursive] Error 1 
make[2]: Leaving directory `/var/tmp/portage/valgrind-2.0_pre20031012/work/
valgrind-20031012/coregrind' 
make[1]: *** [all-recursive] Error 1 
make[1]: Leaving directory `/var/tmp/portage/valgrind-2.0_pre20031012/work/
valgrind-20031012' 
make: *** [all] Error 2 
 
!!! ERROR: dev-util/valgrind-2.0_pre20031012 failed. 
!!! Function src_compile, Line 37, Exitcode 2 
!!! (no error message) 
 
 

Reproducible: Always
Steps to Reproduce:
1. emerge valgrind 
 



Portage 2.0.49-r15 (default-x86-1.4, gcc-3.3.2, glibc-2.3.2-r8, 2.6.0-test9-mm2) 
================================================================= 
System uname: 2.6.0-test9-mm2 i686 AMD Athlon(tm) XP 1600+ 
Gentoo Base System version 1.4.3.11 
distcc 2.11.2 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled] 
ccache version 2.3 [enabled] 
ACCEPT_KEYWORDS="x86 ~x86" 
AUTOCLEAN="yes" 
CFLAGS="-march=athlon-xp -O3 -ffast-math -funroll-loops -pipe 
-fomit-frame-pointer -msse -mfpmath=sse,387  -falign-functions=16 
-falign-labels=1 -falign-loops=16 -falign-jumps=16 -ftracer" 
CHOST="i686-pc-linux-gnu" 
COMPILER="gcc3" 
CONFIG_PROTECT="/etc /var/qmail/control /usr/kde/2/share/config /usr/kde/3/
share/config /usr/X11R6/lib/X11/xkb /usr/kde/3.2/share/config /usr/share/texmf/
tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/config" 
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d" 
CXXFLAGS="-march=athlon-xp -O3 -ffast-math -funroll-loops -pipe 
-fomit-frame-pointer -msse -mfpmath=sse,387  -falign-functions=16 
-falign-labels=1 -falign-loops=16 -falign-jumps=16 -ftracer" 
DISTDIR="/usr/portage-distfiles" 
FEATURES="autoaddcvs sandbox ccache" 
GENTOO_MIRRORS="http://mirrors.sec.informatik.tu-darmstadt.de/gentoo http://
linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror http://www.ibiblio.org/pub/
Linux/distributions/gentoo http://gentoo.oregonstate.edu" 
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="x86 oss avi gif jpeg libg++ mad mikmod png spell truetype xmms xv zlib gdbm 
berkdb slang readline tetex svga sdl tcpd pam libwww ssl perl python esd imlib gtk 
qt motif opengl ldap X gtk2 3dnow -apm kde cdr dga fbcon mozilla mpeg ncurses 
pdflib quicktime samba sse acpi aalib crypt ipv6 -nls -gnome alsa gpm nptl 
oggvorbis xml2 -java arts encode -debug cups usb foomaticdb prelink snmp mysql 
mmx imap"
Comment 1 Caleb Tennis (RETIRED) gentoo-dev 2003-11-13 09:02:31 UTC
please try out the 2.0.0 release and see if it fixes your problem
Comment 2 Jan Killius 2003-11-13 09:31:16 UTC
No, the bug is not fixed.
Comment 3 Caleb Tennis (RETIRED) gentoo-dev 2003-11-13 09:37:28 UTC
I saw the same bug has already been submitted (by a Gentooer, so I'm guessing you submitted it upstream).  I suppose we'll just have wait for a response from them.

Comment 4 Christopher Rude 2003-11-13 20:46:03 UTC
the same output is recived with 2.0.0, granted I had to change the ebuild because the 2.6 config patch is not needed for a 2.6 kernel anymore.

Portage 2.0.49-r15 (default-x86-1.4, gcc-3.3.2, glibc-2.3.2-r8, 2.6.0-test9-mm2)
=================================================================
System uname: 2.6.0-test9-mm2 i686 AMD Athlon(tm) MP 1900+
Gentoo Base System version 1.4.3.12
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CFLAGS="-march=athlon-xp -O3 -fomit-frame-pointer -pipe -falign-functions=64 -mfpmath=sse -m3dnow -msse -mmmx -ffast-math"
CHOST="i686-pc-linux-gnu"
COMPILER="gcc3"
CONFIG_PROTECT="/etc /var/qmail/control /usr/kde/2/share/config /usr/kde/3/share/config /usr/X11R6/lib/X11/xkb /usr/kde/3.2/share/config /usr/kde/3.1/share/config /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/xdvi/ /usr/share/config"
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d"
CXXFLAGS="-march=athlon-xp -O3 -fomit-frame-pointer -pipe -falign-functions=64 -mfpmath=sse -m3dnow -msse -mmmx -ffast-math"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs -sandbox ccache buildpkg"
GENTOO_MIRRORS="http://gentoo.oregonstate.edu http://distro.ibiblio.org/pub/Linux/distributions/gentoo"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
Comment 5 Howard B. Golden 2003-11-30 12:10:26 UTC
Caleb, in comment #3, you said that you saw the same bug submitted upstream. I looked at bugs.kde.org for all valgrind bugs. I didn't see this bug there. I saw http://bugs.kde.org/show_bug.cgi?id=68360 , but that isn't exactly what's happening here. Am I looking in the wrong place?
Comment 6 Tony Vroon (RETIRED) gentoo-dev 2003-12-17 04:56:24 UTC
Upstream released 2.1.0, the NEWS-entry "68360: Valgrind does not compile against 2.6.0-testX kernels" looked quite hopeful, but I see the exact same error with these sources.
Comment 7 SpanKY gentoo-dev 2003-12-24 14:17:58 UTC
if we run this sed script we get a lot less errors:
sed -i \
 -e 's:__m_owner:__data.__owner:g' \
 -e 's:__m_kind:__data.__kind:g' \
 -e 's:__m_count:__data.__count:g' \
 coregrind/vg_scheduler.c \
 coregrind/vg_libpthread.c \
 include/vg_skin.h
Comment 8 SpanKY gentoo-dev 2003-12-24 14:31:40 UTC
then it seems that a _pthread_descr no longer exists so if we look at bits/pthreadtypes.h
we now find that owner is of type int and not _pthread_descr ...

so if we put '#define _pthread_descr int' inside of vg_include.h it makes more things happy
and lets vg_scheduler.c compile

next up is vg_libpthread.c ... at this point we see that it gets pretty pissed
at not knowing anything about the innerards of pthread_attr_t ... and looking at
bits/pthreadtypes.h, i guess you're not supposed to :)
anyways, it seems the interface has changed from using members of this struct
to function calls ... pthread.h has gained a whole bunch of get/set functions:
old way:
myg = (pthread_attr_t*)attr->__guardsize
new way:
pthread_attr_setguardsize(attr, &myg)
so on and so forth for
Comment 9 SpanKY gentoo-dev 2003-12-24 14:38:29 UTC
err i'm an idiot ;)
the entire point of vg_libpthread.c is provide a wrapper around all the pthread
functions which means knowing the inner structure of the pthread stuff ... so
scratch that last comment about vg_libpthread.c heh
Comment 10 Gen Zhang 2004-02-05 11:02:25 UTC
you wrote:
> pthread_attr_setguardsize(attr, &myg)
pthread_attr_GETguardsize ??
Comment 11 David Henry 2004-02-11 04:32:09 UTC
There is a bug report for this here http://bugs.kde.org/show_bug.cgi?id=69616

The patch applies against CVS and compiles and runs properly with NPTL. A few chunks fail against 2.1.0 though.
Comment 12 Sami Nieminen 2004-02-11 07:50:27 UTC
Created attachment 25410 [details, diff]
Diff to make valgrind-2.1.0 compile against nptl version of pthreadtypes.h

This diff is based on the work by Nicholas Nethercote. See
http://bugs.kde.org/show_bug.cgi?id=69616 for more info.
Comment 13 Caleb Tennis (RETIRED) gentoo-dev 2004-02-11 10:29:37 UTC
Should that be applied across the board, or only for nptl folks?
Comment 14 Gen Zhang 2004-02-11 11:33:05 UTC
Compiles, but when run, gives:

$ valgrind ./hello
grep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/usr/bin/valgrind: './hello' not found in $PATH, aborting.

(where hello is a "hello world" program)
Should I open another bug report for this?
Comment 15 Christopher Rude 2004-02-11 20:39:12 UTC
I had manualy patched 2.1.0 as well, and ran into the libc.so.6 problem... cvs on the other hand seemes to be no problem.

Caleb.. this should be safe for non nptl people as well because it is simply re impliments parts of the old pthreadtyps within valgrind. thus taking care of the changes made in the new version of the file without relying on the new version of the file.

err yea
Comment 16 Christopher Rude 2004-02-11 20:48:16 UTC
btw... I tried this patch against the 2.1.0 archive, and i run into the libc.6.so error again.
Comment 17 Christopher Rude 2004-02-11 21:26:00 UTC
Created attachment 25450 [details, diff]
1 of 3 part patch

first of 2 patches to bring 2.1.0 up to cvs
Comment 18 Christopher Rude 2004-02-11 21:29:18 UTC
Created attachment 25451 [details, diff]
part 2 of 3

this gets us to cvs as of 2/11/2004 (still runs as 2.1)
Comment 19 Christopher Rude 2004-02-11 21:31:00 UTC
Created attachment 25452 [details, diff]
part 3 of 3 

this patches to work with nptl. I have tested and it all seems to work for me

Thanks again
Comment 20 Christopher Rude 2004-02-11 21:50:51 UTC
btw the new version of valgrind will requiere you to specify the tool to use, as they have removed valgrinds defaulting.

ie 
valgrind ./hello

will out put the same as just valgrind

so you will need to do something like

valgrind --tool=<tool> ./hello

<tool> can be helgrind, addrcheck, cachegrind, memcheck, corecheck, lackey, none.

of course you can setup a config file that will use a default action
Comment 21 SpanKY gentoo-dev 2004-02-16 13:59:51 UTC
i can verify that the 3 part patch set worked for me ...

now if only valgrind would stop lying to me and telling me my program leaks memory
Comment 22 SpanKY gentoo-dev 2004-02-29 14:42:43 UTC
*** Bug 43305 has been marked as a duplicate of this bug. ***
Comment 23 Andreas Simon 2004-03-15 04:41:13 UTC
BTW this issue is already fixed in valgrind's CVS, which means this issue will be nonexistent with the next release.

Here is the fix's mention in the CVS log:
date: 2004/02/28 15:40:36;  author: nethercote;  state: Exp;  lines: +80 -108
Some newer systems have a new version of pthreadtypes.h that comes from glibc
2.3.3, which is binary-compatible, but not source compatible with the old one,
which came from LinuxThreads.  We were using the types defined in the old one,
which caused compilation errors on systems using the new one.

This commit introduces our own versions of these types.  Our versions are laid
out identically to the LinuxThreads ones, but the field names are different.
We convert all pthread types to our versions before using them, so we don't
rely on the pthreadtypes.h types any more.  Hopefully this will fix the
problem;  I have three reports that it does.  Let's see...
Comment 24 Andreas Simon 2004-03-15 04:51:23 UTC
Oops... Next time I should read _all_ comments in a bug report.
;-)
Comment 25 Ortwin Glueck 2004-03-27 01:24:38 UTC
Valgrind 2.1.1 compiles with the new NPTL headers. Please include 2.1.1 in the portage tree. You should also include calltree 0.9.7 that depends on >=valgrind-2.0.0

I had to put both of them in my overlay tree because digikam depends on them.
Comment 26 Caleb Tennis (RETIRED) gentoo-dev 2004-04-05 11:34:07 UTC
2.1.1 is now in portage
Comment 27 SpanKY gentoo-dev 2004-07-24 22:36:12 UTC
*** Bug 56622 has been marked as a duplicate of this bug. ***