|
From: Ivan S. L. <dr...@gm...> - 2010-09-08 13:02:26
Attachments:
signature.asc
|
Hello.
I'm writed a simple pthreads program and can't understand Valgrind
output because thre is no error in my case I think ;)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
extern "C" {
void * run_handle(void * param) {
printf("tra-la-la\n");
return 0;
}
}
int main(int argc, char** argv) {
pthread_t t;
pthread_create(&t, 0, run_handle, 0);
sleep(10);
return 0;
}
compile it
gcc ./main.cpp -o main -pthread -D_REENTRANT -D_THREAD_SAFE -lpthread
and valgrind
valgrind --tool=helgrind -v ./main
ArchLinux, i686, valgrind-3.5.0
why there is errors?
==12868== Helgrind, a thread error detector
==12868== Copyright (C) 2007-2009, and GNU GPL'd, by OpenWorks LLP et
al. ==12868== Using Valgrind-3.5.0 and LibVEX; rerun with -h for
copyright info ==12868== Command: ./main
==12868==
--12868-- Valgrind options:
--12868-- --tool=helgrind
--12868-- -v
--12868-- Contents of /proc/version:
--12868-- Linux version 2.6.35-ARCH (tobias@T-POWA-LX) (gcc version
4.5.1 (GCC) ) #1 SMP PREEMPT Fri Aug 27 16:22:18 UTC 2010 --12868--
Arch and hwcaps: X86, x86-sse1-sse2 --12868-- Page sizes: currently
4096, max supported 4096 --12868-- Valgrind library
directory: /usr/lib/valgrind --12868-- Reading syms
from /lib/ld-2.12.1.so (0x4000000) --12868-- Reading syms
from /home/dront/Develop/git/crossplatform/FoundationTest/main
(0x8048000) --12868-- Reading syms
from /usr/lib/valgrind/helgrind-x86-linux (0x38000000) --12868--
object doesn't have a symbol table --12868-- object doesn't have a
dynamic symbol table --12868-- Reading suppressions
file: /usr/lib/valgrind/default.supp --12868-- Reading syms
from /usr/lib/valgrind/vgpreload_core-x86-linux.so (0x401f000)
--12868-- Reading syms
from /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so (0x4021000)
--12868-- REDIR: 0x4016c20 (index) redirected to 0x4027650 (index)
--12868-- REDIR: 0x4016dc0 (strlen) redirected to 0x4027730 (strlen)
--12868-- Reading syms from /lib/libpthread-2.12.1.so (0x404e000)
--12868-- Reading syms from /lib/libc-2.12.1.so (0x4068000)
--12868-- object doesn't have a symbol table --12868-- REDIR:
0x40dc300 (index) redirected to 0x40275d0 (index) --12868-- REDIR:
0x40540b0 (pthread_create@@GLIBC_2.1) redirected to 0x40252f0
(pthread_create@*) --12868-- REDIR: 0x40d9c20 (calloc) redirected to
0x40232f0 (calloc) --12868-- REDIR: 0x40dc9d0 (strlen) redirected to
0x4027710 (strlen) tra-la-la ==12868== Thread #1 is the program's root
thread ==12868== ==12868== Thread #2 was created ==12868== at
0x41371F8: clone (in /lib/libc-2.12.1.so) ==12868== by 0x4054425:
pthread_create@@GLIBC_2.1 (in /lib/libpthread-2.12.1.so) ==12868==
by 0x40251E1: pthread_create_WRK
(in /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so) ==12868== by
0x80484D9: main
(in /home/dront/Develop/git/crossplatform/FoundationTest/main)
==12868== ==12868== Possible data race during read of size 4 at
0xbe87819c by thread #1 ==12868== at 0x40251EF: pthread_create_WRK
(in /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so) ==12868== by
0x80484D9: main
(in /home/dront/Develop/git/crossplatform/FoundationTest/main)
==12868== This conflicts with a previous write of size 4 by thread #2
==12868== at 0x40252C9: mythread_wrapper
(in /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so) ==12868== by
0x4053E5F: start_thread (in /lib/libpthread-2.12.1.so) ==12868== by
0x413720D: clone (in /lib/libc-2.12.1.so) ==12868== --12868-- REDIR:
0x40d9160 (free) redirected to 0x4023da0 (free) --12868-- REDIR:
0x40561f0 (pthread_mutex_lock) redirected to 0x4025680
(pthread_mutex_lock) --12868-- REDIR: 0x40577c0 (pthread_mutex_unlock)
redirected to 0x4025a60 (pthread_mutex_unlock) ==12868== ==12868==
ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 23 from 23)
==12868== ==12868== 1 errors in context 1 of 1: ==12868== Possible data
race during read of size 4 at 0xbe87819c by thread #1 ==12868== at
0x40251EF: pthread_create_WRK
(in /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so) ==12868== by
0x80484D9: main
(in /home/dront/Develop/git/crossplatform/FoundationTest/main)
==12868== This conflicts with a previous write of size 4 by thread #2
==12868== at 0x40252C9: mythread_wrapper
(in /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so) ==12868== by
0x4053E5F: start_thread (in /lib/libpthread-2.12.1.so) ==12868== by
0x413720D: clone (in /lib/libc-2.12.1.so) ==12868== --12868-- --12868--
used_suppression: 23 helgrind-glibc2X-004 ==12868== ==12868== ERROR
SUMMARY: 1 errors from 1 contexts (suppressed: 23 from 23)
cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 2
model name : Intel(R) Pentium(R) 4 CPU 3.06GHz
stepping : 7
cpu MHz : 3066.602
cache size : 512 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr
pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe
pebs bts cid bogomips : 6135.75 clflush size : 64
cache_alignment : 128
address sizes : 36 bits physical, 32 bits virtual
power management:
processor : 1
vendor_id : GenuineIntel
cpu family : 15
model : 2
model name : Intel(R) Pentium(R) 4 CPU 3.06GHz
stepping : 7
cpu MHz : 3066.602
cache size : 512 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 1
apicid : 1
initial apicid : 1
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr
pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe
pebs bts cid bogomips : 6135.53 clflush size : 64
cache_alignment : 128
address sizes : 36 bits physical, 32 bits virtual
power management:
Regards,
Ivan
|
|
From: Konstantin S. <kon...@gm...> - 2010-09-08 13:13:14
|
On Wed, Sep 8, 2010 at 5:02 PM, Ivan S. Lyapunov <dr...@gm...> wrote:
> Hello.
>
> I'm writed a simple pthreads program and can't understand Valgrind
> output because thre is no error in my case I think ;)
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <pthread.h>
>
> extern "C" {
>
> void * run_handle(void * param) {
> printf("tra-la-la\n");
> return 0;
> }
> }
>
> int main(int argc, char** argv) {
> pthread_t t;
> pthread_create(&t, 0, run_handle, 0);
>
> sleep(10);
> return 0;
> }
>
>
> compile it
> gcc ./main.cpp -o main -pthread -D_REENTRANT -D_THREAD_SAFE -lpthread
>
As the first step, try adding "-g" to the compile command.
--kcc
>
> and valgrind
> valgrind --tool=helgrind -v ./main
>
> ArchLinux, i686, valgrind-3.5.0
>
> why there is errors?
>
> ==12868== Helgrind, a thread error detector
> ==12868== Copyright (C) 2007-2009, and GNU GPL'd, by OpenWorks LLP et
> al. ==12868== Using Valgrind-3.5.0 and LibVEX; rerun with -h for
> copyright info ==12868== Command: ./main
> ==12868==
> --12868-- Valgrind options:
> --12868-- --tool=helgrind
> --12868-- -v
> --12868-- Contents of /proc/version:
> --12868-- Linux version 2.6.35-ARCH (tobias@T-POWA-LX) (gcc version
> 4.5.1 (GCC) ) #1 SMP PREEMPT Fri Aug 27 16:22:18 UTC 2010 --12868--
> Arch and hwcaps: X86, x86-sse1-sse2 --12868-- Page sizes: currently
> 4096, max supported 4096 --12868-- Valgrind library
> directory: /usr/lib/valgrind --12868-- Reading syms
> from /lib/ld-2.12.1.so (0x4000000) --12868-- Reading syms
> from /home/dront/Develop/git/crossplatform/FoundationTest/main
> (0x8048000) --12868-- Reading syms
> from /usr/lib/valgrind/helgrind-x86-linux (0x38000000) --12868--
> object doesn't have a symbol table --12868-- object doesn't have a
> dynamic symbol table --12868-- Reading suppressions
> file: /usr/lib/valgrind/default.supp --12868-- Reading syms
> from /usr/lib/valgrind/vgpreload_core-x86-linux.so (0x401f000)
> --12868-- Reading syms
> from /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so (0x4021000)
> --12868-- REDIR: 0x4016c20 (index) redirected to 0x4027650 (index)
> --12868-- REDIR: 0x4016dc0 (strlen) redirected to 0x4027730 (strlen)
> --12868-- Reading syms from /lib/libpthread-2.12.1.so (0x404e000)
> --12868-- Reading syms from /lib/libc-2.12.1.so (0x4068000)
> --12868-- object doesn't have a symbol table --12868-- REDIR:
> 0x40dc300 (index) redirected to 0x40275d0 (index) --12868-- REDIR:
> 0x40540b0 (pthread_create@@GLIBC_2.1) redirected to 0x40252f0
> (pthread_create@*) --12868-- REDIR: 0x40d9c20 (calloc) redirected to
> 0x40232f0 (calloc) --12868-- REDIR: 0x40dc9d0 (strlen) redirected to
> 0x4027710 (strlen) tra-la-la ==12868== Thread #1 is the program's root
> thread ==12868== ==12868== Thread #2 was created ==12868== at
> 0x41371F8: clone (in /lib/libc-2.12.1.so) ==12868== by 0x4054425:
> pthread_create@@GLIBC_2.1 (in /lib/libpthread-2.12.1.so) ==12868==
> by 0x40251E1: pthread_create_WRK
> (in /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so) ==12868== by
> 0x80484D9: main
> (in /home/dront/Develop/git/crossplatform/FoundationTest/main)
> ==12868== ==12868== Possible data race during read of size 4 at
> 0xbe87819c by thread #1 ==12868== at 0x40251EF: pthread_create_WRK
> (in /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so) ==12868== by
> 0x80484D9: main
> (in /home/dront/Develop/git/crossplatform/FoundationTest/main)
> ==12868== This conflicts with a previous write of size 4 by thread #2
> ==12868== at 0x40252C9: mythread_wrapper
> (in /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so) ==12868== by
> 0x4053E5F: start_thread (in /lib/libpthread-2.12.1.so) ==12868== by
> 0x413720D: clone (in /lib/libc-2.12.1.so) ==12868== --12868-- REDIR:
> 0x40d9160 (free) redirected to 0x4023da0 (free) --12868-- REDIR:
> 0x40561f0 (pthread_mutex_lock) redirected to 0x4025680
> (pthread_mutex_lock) --12868-- REDIR: 0x40577c0 (pthread_mutex_unlock)
> redirected to 0x4025a60 (pthread_mutex_unlock) ==12868== ==12868==
> ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 23 from 23)
> ==12868== ==12868== 1 errors in context 1 of 1: ==12868== Possible data
> race during read of size 4 at 0xbe87819c by thread #1 ==12868== at
> 0x40251EF: pthread_create_WRK
> (in /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so) ==12868== by
> 0x80484D9: main
> (in /home/dront/Develop/git/crossplatform/FoundationTest/main)
> ==12868== This conflicts with a previous write of size 4 by thread #2
> ==12868== at 0x40252C9: mythread_wrapper
> (in /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so) ==12868== by
> 0x4053E5F: start_thread (in /lib/libpthread-2.12.1.so) ==12868== by
> 0x413720D: clone (in /lib/libc-2.12.1.so) ==12868== --12868-- --12868--
> used_suppression: 23 helgrind-glibc2X-004 ==12868== ==12868== ERROR
> SUMMARY: 1 errors from 1 contexts (suppressed: 23 from 23)
>
>
>
> cat /proc/cpuinfo
> processor : 0
> vendor_id : GenuineIntel
> cpu family : 15
> model : 2
> model name : Intel(R) Pentium(R) 4 CPU 3.06GHz
> stepping : 7
> cpu MHz : 3066.602
> cache size : 512 KB
> physical id : 0
> siblings : 2
> core id : 0
> cpu cores : 1
> apicid : 0
> initial apicid : 0
> fdiv_bug : no
> hlt_bug : no
> f00f_bug : no
> coma_bug : no
> fpu : yes
> fpu_exception : yes
> cpuid level : 2
> wp : yes
> flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr
> pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe
> pebs bts cid bogomips : 6135.75 clflush size : 64
> cache_alignment : 128
> address sizes : 36 bits physical, 32 bits virtual
> power management:
>
> processor : 1
> vendor_id : GenuineIntel
> cpu family : 15
> model : 2
> model name : Intel(R) Pentium(R) 4 CPU 3.06GHz
> stepping : 7
> cpu MHz : 3066.602
> cache size : 512 KB
> physical id : 0
> siblings : 2
> core id : 0
> cpu cores : 1
> apicid : 1
> initial apicid : 1
> fdiv_bug : no
> hlt_bug : no
> f00f_bug : no
> coma_bug : no
> fpu : yes
> fpu_exception : yes
> cpuid level : 2
> wp : yes
> flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr
> pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe
> pebs bts cid bogomips : 6135.53 clflush size : 64
> cache_alignment : 128
> address sizes : 36 bits physical, 32 bits virtual
> power management:
>
>
> Regards,
> Ivan
>
>
> ------------------------------------------------------------------------------
> This SF.net Dev2Dev email is sponsored by:
>
> Show off your parallel programming skills.
> Enter the Intel(R) Threading Challenge 2010.
> http://p.sf.net/sfu/intel-thread-sfd
> _______________________________________________
> Valgrind-users mailing list
> Val...@li...
> https://lists.sourceforge.net/lists/listinfo/valgrind-users
>
>
|
|
From: Ivan S. L. <dr...@gm...> - 2010-09-08 13:26:50
Attachments:
signature.asc
|
В Wed, 8 Sep 2010 17:12:46 +0400
Konstantin Serebryany <kon...@gm...> пишет:
It still the same.
gcc ./main.cpp -o main -g -pthread -D_REENTRANT -D_THREAD_SAFE -lpthread
Regards,
Ivan
==12972== Thread #1 is the program's root thread
==12972==
==12972== Thread #2 was created
==12972== at 0x41371F8: clone (in /lib/libc-2.12.1.so)
==12972== by 0x4054425: pthread_create@@GLIBC_2.1 (in /lib/libpthread-2.12.1.so)
==12972== by 0x40251E1: pthread_create_WRK (in /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so)
==12972== by 0x80484D9: main (main.cpp:84)
==12972==
==12972== Possible data race during read of size 4 at 0xbecc119c by thread #1
==12972== at 0x40251FD: pthread_create_WRK (in /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so)
==12972== by 0x80484D9: main (main.cpp:84)
==12972== This conflicts with a previous write of size 4 by thread #2
==12972== at 0x40252C9: mythread_wrapper (in /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so)
==12972== by 0x4053E5F: start_thread (in /lib/libpthread-2.12.1.so)
==12972== by 0x413720D: clone (in /lib/libc-2.12.1.so)
==12972==
tra-la-la
> On Wed, Sep 8, 2010 at 5:02 PM, Ivan S. Lyapunov <dr...@gm...>
> wrote:
>
> > Hello.
> >
> > I'm writed a simple pthreads program and can't understand Valgrind
> > output because thre is no error in my case I think ;)
> >
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <unistd.h>
> > #include <pthread.h>
> >
> > extern "C" {
> >
> > void * run_handle(void * param) {
> > printf("tra-la-la\n");
> > return 0;
> > }
> > }
> >
> > int main(int argc, char** argv) {
> > pthread_t t;
> > pthread_create(&t, 0, run_handle, 0);
> >
> > sleep(10);
> > return 0;
> > }
> >
> >
> > compile it
> > gcc ./main.cpp -o main -pthread -D_REENTRANT -D_THREAD_SAFE
> > -lpthread
> >
>
> As the first step, try adding "-g" to the compile command.
>
> --kcc
>
>
|
|
From: Konstantin S. <kon...@gm...> - 2010-09-08 13:36:45
|
Hm. indeed, I see this too.
Most likely, helgrind lacks a proper suppression.
Julian,
I can see this suppression:
{
helgrind-glibc2X-102
Helgrind:Race
fun:mythread_wrapper
obj:/lib*/libpthread-2.*so*
}
but it doesn't match because for some reason the stack contains just one
frame.
--kcc
2010/9/8 Ivan S. Lyapunov <dr...@gm...>
> В Wed, 8 Sep 2010 17:12:46 +0400
> Konstantin Serebryany <kon...@gm...> пишет:
>
> It still the same.
>
> gcc ./main.cpp -o main -g -pthread -D_REENTRANT -D_THREAD_SAFE -lpthread
>
> Regards,
> Ivan
>
> ==12972== Thread #1 is the program's root thread
> ==12972==
> ==12972== Thread #2 was created
> ==12972== at 0x41371F8: clone (in /lib/libc-2.12.1.so)
> ==12972== by 0x4054425: pthread_create@@GLIBC_2.1 (in /lib/
> libpthread-2.12.1.so)
> ==12972== by 0x40251E1: pthread_create_WRK (in
> /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so)
> ==12972== by 0x80484D9: main (main.cpp:84)
> ==12972==
> ==12972== Possible data race during read of size 4 at 0xbecc119c by thread
> #1
> ==12972== at 0x40251FD: pthread_create_WRK (in
> /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so)
> ==12972== by 0x80484D9: main (main.cpp:84)
> ==12972== This conflicts with a previous write of size 4 by thread #2
> ==12972== at 0x40252C9: mythread_wrapper (in
> /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so)
> ==12972== by 0x4053E5F: start_thread (in /lib/libpthread-2.12.1.so)
> ==12972== by 0x413720D: clone (in /lib/libc-2.12.1.so)
> ==12972==
> tra-la-la
>
>
> > On Wed, Sep 8, 2010 at 5:02 PM, Ivan S. Lyapunov <dr...@gm...>
> > wrote:
> >
> > > Hello.
> > >
> > > I'm writed a simple pthreads program and can't understand Valgrind
> > > output because thre is no error in my case I think ;)
> > >
> > > #include <stdio.h>
> > > #include <stdlib.h>
> > > #include <unistd.h>
> > > #include <pthread.h>
> > >
> > > extern "C" {
> > >
> > > void * run_handle(void * param) {
> > > printf("tra-la-la\n");
> > > return 0;
> > > }
> > > }
> > >
> > > int main(int argc, char** argv) {
> > > pthread_t t;
> > > pthread_create(&t, 0, run_handle, 0);
> > >
> > > sleep(10);
> > > return 0;
> > > }
> > >
> > >
> > > compile it
> > > gcc ./main.cpp -o main -pthread -D_REENTRANT -D_THREAD_SAFE
> > > -lpthread
> > >
> >
> > As the first step, try adding "-g" to the compile command.
> >
> > --kcc
> >
> >
>
|
|
From: Konstantin S. <kon...@gm...> - 2010-09-08 13:45:20
|
Correction.
On my machine I get:
==30585== Possible data race during write of size 8 at 0x7ff0001d0 by thread
#2
==30585== at 0x4C2C336: mythread_wrapper (hg_intercepts.c:211)
==30585== This conflicts with a previous read of size 8 by thread #1
==30585== at 0x4C2C227: pthread_create_WRK (hg_intercepts.c:246)
==30585== by 0x4C2C2B9: pthread_create@* (hg_intercepts.c:268)
==30585== by 0x40071A: main (in /tmp/main)
Ivan's report is
==12972== Possible data race during read of size 4 at 0xbecc119c by thread
#1
==12972== at 0x40251FD: pthread_create_WRK (in
/usr/lib/valgrind/vgpreload_helgrind-x86-linux.so)
==12972== by 0x80484D9: main (main.cpp:84)
....
and it is not suppressed because there is only this suppression:
{
helgrind-glibc2X-112
Helgrind:Race
fun:pthread_create_WRK
fun:pthread_create@*
}
--kcc
2010/9/8 Konstantin Serebryany <kon...@gm...>
> Hm. indeed, I see this too.
> Most likely, helgrind lacks a proper suppression.
>
> Julian,
> I can see this suppression:
> {
>
>
> helgrind-glibc2X-102
>
>
> Helgrind:Race
>
>
> fun:mythread_wrapper
>
>
> obj:/lib*/libpthread-2.*so*
>
>
> }
>
> but it doesn't match because for some reason the stack contains just one
> frame.
>
> --kcc
>
>
>
>
> 2010/9/8 Ivan S. Lyapunov <dr...@gm...>
>
> В Wed, 8 Sep 2010 17:12:46 +0400
>> Konstantin Serebryany <kon...@gm...> пишет:
>>
>> It still the same.
>>
>> gcc ./main.cpp -o main -g -pthread -D_REENTRANT -D_THREAD_SAFE -lpthread
>>
>> Regards,
>> Ivan
>>
>> ==12972== Thread #1 is the program's root thread
>> ==12972==
>> ==12972== Thread #2 was created
>> ==12972== at 0x41371F8: clone (in /lib/libc-2.12.1.so)
>> ==12972== by 0x4054425: pthread_create@@GLIBC_2.1 (in /lib/
>> libpthread-2.12.1.so)
>> ==12972== by 0x40251E1: pthread_create_WRK (in
>> /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so)
>> ==12972== by 0x80484D9: main (main.cpp:84)
>> ==12972==
>> ==12972== Possible data race during read of size 4 at 0xbecc119c by thread
>> #1
>> ==12972== at 0x40251FD: pthread_create_WRK (in
>> /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so)
>> ==12972== by 0x80484D9: main (main.cpp:84)
>> ==12972== This conflicts with a previous write of size 4 by thread #2
>> ==12972== at 0x40252C9: mythread_wrapper (in
>> /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so)
>> ==12972== by 0x4053E5F: start_thread (in /lib/libpthread-2.12.1.so)
>> ==12972== by 0x413720D: clone (in /lib/libc-2.12.1.so)
>> ==12972==
>> tra-la-la
>>
>>
>> > On Wed, Sep 8, 2010 at 5:02 PM, Ivan S. Lyapunov <dr...@gm...>
>> > wrote:
>> >
>> > > Hello.
>> > >
>> > > I'm writed a simple pthreads program and can't understand Valgrind
>> > > output because thre is no error in my case I think ;)
>> > >
>> > > #include <stdio.h>
>> > > #include <stdlib.h>
>> > > #include <unistd.h>
>> > > #include <pthread.h>
>> > >
>> > > extern "C" {
>> > >
>> > > void * run_handle(void * param) {
>> > > printf("tra-la-la\n");
>> > > return 0;
>> > > }
>> > > }
>> > >
>> > > int main(int argc, char** argv) {
>> > > pthread_t t;
>> > > pthread_create(&t, 0, run_handle, 0);
>> > >
>> > > sleep(10);
>> > > return 0;
>> > > }
>> > >
>> > >
>> > > compile it
>> > > gcc ./main.cpp -o main -pthread -D_REENTRANT -D_THREAD_SAFE
>> > > -lpthread
>> > >
>> >
>> > As the first step, try adding "-g" to the compile command.
>> >
>> > --kcc
>> >
>> >
>>
>
>
|
|
From: Ivan S. L. <dr...@gm...> - 2010-09-08 13:56:45
Attachments:
signature.asc
|
В Wed, 8 Sep 2010 17:44:52 +0400
Konstantin Serebryany <kon...@gm...> пишет:
simply making
for (int i = 0; i < 1000; ++i)
pthread_create(&t, 0, run_handle, 0);
increases error count slightly
regards,
Ivan
> Correction.
>
> On my machine I get:
> ==30585== Possible data race during write of size 8 at 0x7ff0001d0 by
> thread #2
> ==30585== at 0x4C2C336: mythread_wrapper (hg_intercepts.c:211)
> ==30585== This conflicts with a previous read of size 8 by thread #1
> ==30585== at 0x4C2C227: pthread_create_WRK (hg_intercepts.c:246)
> ==30585== by 0x4C2C2B9: pthread_create@* (hg_intercepts.c:268)
> ==30585== by 0x40071A: main (in /tmp/main)
>
> Ivan's report is
> ==12972== Possible data race during read of size 4 at 0xbecc119c by
> thread #1
> ==12972== at 0x40251FD: pthread_create_WRK (in
> /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so)
> ==12972== by 0x80484D9: main (main.cpp:84)
> ....
>
> and it is not suppressed because there is only this suppression:
> {
>
>
> helgrind-glibc2X-112
>
>
> Helgrind:Race
>
>
> fun:pthread_create_WRK
>
>
> fun:pthread_create@*
>
>
> }
>
>
> --kcc
>
> 2010/9/8 Konstantin Serebryany <kon...@gm...>
>
> > Hm. indeed, I see this too.
> > Most likely, helgrind lacks a proper suppression.
> >
> > Julian,
> > I can see this suppression:
> > {
> >
> >
> > helgrind-glibc2X-102
> >
> >
> > Helgrind:Race
> >
> >
> > fun:mythread_wrapper
> >
> >
> > obj:/lib*/libpthread-2.*so*
> >
> >
> > }
> >
> > but it doesn't match because for some reason the stack contains
> > just one frame.
> >
> > --kcc
> >
> >
> >
> >
> > 2010/9/8 Ivan S. Lyapunov <dr...@gm...>
> >
> > В Wed, 8 Sep 2010 17:12:46 +0400
> >> Konstantin Serebryany <kon...@gm...> пишет:
> >>
> >> It still the same.
> >>
> >> gcc ./main.cpp -o main -g -pthread -D_REENTRANT -D_THREAD_SAFE
> >> -lpthread
> >>
> >> Regards,
> >> Ivan
> >>
> >> ==12972== Thread #1 is the program's root thread
> >> ==12972==
> >> ==12972== Thread #2 was created
> >> ==12972== at 0x41371F8: clone (in /lib/libc-2.12.1.so)
> >> ==12972== by 0x4054425: pthread_create@@GLIBC_2.1 (in /lib/
> >> libpthread-2.12.1.so)
> >> ==12972== by 0x40251E1: pthread_create_WRK (in
> >> /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so)
> >> ==12972== by 0x80484D9: main (main.cpp:84)
> >> ==12972==
> >> ==12972== Possible data race during read of size 4 at 0xbecc119c
> >> by thread #1
> >> ==12972== at 0x40251FD: pthread_create_WRK (in
> >> /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so)
> >> ==12972== by 0x80484D9: main (main.cpp:84)
> >> ==12972== This conflicts with a previous write of size 4 by
> >> thread #2 ==12972== at 0x40252C9: mythread_wrapper (in
> >> /usr/lib/valgrind/vgpreload_helgrind-x86-linux.so)
> >> ==12972== by 0x4053E5F: start_thread
> >> (in /lib/libpthread-2.12.1.so) ==12972== by 0x413720D: clone
> >> (in /lib/libc-2.12.1.so) ==12972==
> >> tra-la-la
> >>
> >>
> >> > On Wed, Sep 8, 2010 at 5:02 PM, Ivan S. Lyapunov
> >> > <dr...@gm...> wrote:
> >> >
> >> > > Hello.
> >> > >
> >> > > I'm writed a simple pthreads program and can't understand
> >> > > Valgrind output because thre is no error in my case I think ;)
> >> > >
> >> > > #include <stdio.h>
> >> > > #include <stdlib.h>
> >> > > #include <unistd.h>
> >> > > #include <pthread.h>
> >> > >
> >> > > extern "C" {
> >> > >
> >> > > void * run_handle(void * param) {
> >> > > printf("tra-la-la\n");
> >> > > return 0;
> >> > > }
> >> > > }
> >> > >
> >> > > int main(int argc, char** argv) {
> >> > > pthread_t t;
> >> > > pthread_create(&t, 0, run_handle, 0);
> >> > >
> >> > > sleep(10);
> >> > > return 0;
> >> > > }
> >> > >
> >> > >
> >> > > compile it
> >> > > gcc ./main.cpp -o main -pthread -D_REENTRANT -D_THREAD_SAFE
> >> > > -lpthread
> >> > >
> >> >
> >> > As the first step, try adding "-g" to the compile command.
> >> >
> >> > --kcc
> >> >
> >> >
> >>
> >
> >
|