|
From: <kei...@te...> - 2006-09-01 04:18:07
|
Hi.
I got the following leak report when I run valgrind-3.1.1 for =
multithread program=20
which calls pthread_exit().
I searched valgrind mailinglist for bugs in pthread library, and found =
out that=20
valgrind-2.4.0 has some bugs in pthread library.
If the program doesn't call pthread_exit(), valgrind doesn't complain =
about it.
Now, I'm wondering if valgrind-3.1.1 has the same bug.
Can this leak report be safely suppressed?
Thanks in advance.
Keishi Sonoda
kei...@te...
TEST PROGRAM : test_thread.c
#include <stdio.h>
#include <pthread.h>
void *thread1(void *arg)
{
pthread_exit("thread1 done");
}
int main()
{
int tid;
if (0 =3D=3D pthread_create((pthread_t *)tid, NULL, thread1, 0))
pthread_join(tid, 0);
return 0;
}
And, ERROR REPORT
valgrind --leak-check=3Dfull --leak-resolution=3Dhigh =
--show-reachable=3Dyes --num-callers=3D20 ./test_thread
=3D=3D7986=3D=3D Memcheck, a memory error detector.
=3D=3D7986=3D=3D Copyright (C) 2002-2005, and GNU GPL'd, by Julian =
Seward et al.
=3D=3D7986=3D=3D Using LibVEX rev 1575, a library for dynamic binary =
translation.
=3D=3D7986=3D=3D Copyright (C) 2004-2005, and GNU GPL'd, by OpenWorks =
LLP.
=3D=3D7986=3D=3D Using valgrind-3.1.1, a dynamic binary instrumentation =
framework.
=3D=3D7986=3D=3D Copyright (C) 2000-2005, and GNU GPL'd, by Julian =
Seward et al.
=3D=3D7986=3D=3D For more details, rerun with: -v
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D Use of uninitialised value of size 4
=3D=3D7986=3D=3D at 0x4040F05: pthread_create@@GLIBC_2.1 =
(pthread_create.c:441)
=3D=3D7986=3D=3D by 0x804846F: main (in /root/test_thread)
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D Use of uninitialised value of size 4
=3D=3D7986=3D=3D at 0x4041B98: pthread_join (pthread_join.c:43)
=3D=3D7986=3D=3D by 0x8048483: main (in /root/test_thread)
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D Use of uninitialised value of size 4
=3D=3D7986=3D=3D at 0x4041BA6: pthread_join (pthread_join.c:48)
=3D=3D7986=3D=3D by 0x8048483: main (in /root/test_thread)
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D Conditional jump or move depends on uninitialised =
value(s)
=3D=3D7986=3D=3D at 0x4041BAC: pthread_join (pthread_join.c:48)
=3D=3D7986=3D=3D by 0x8048483: main (in /root/test_thread)
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D Conditional jump or move depends on uninitialised =
value(s)
=3D=3D7986=3D=3D at 0x4041BBC: pthread_join (pthread_join.c:53)
=3D=3D7986=3D=3D by 0x8048483: main (in /root/test_thread)
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D Conditional jump or move depends on uninitialised =
value(s)
=3D=3D7986=3D=3D at 0x4041BCB: pthread_join (pthread_join.c:53)
=3D=3D7986=3D=3D by 0x8048483: main (in /root/test_thread)
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D Use of uninitialised value of size 4
=3D=3D7986=3D=3D at 0x4041BD6: pthread_join (pthread_join.c:71)
=3D=3D7986=3D=3D by 0x8048483: main (in /root/test_thread)
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D ERROR SUMMARY: 7 errors from 7 contexts (suppressed: 15 =
from 2)
=3D=3D7986=3D=3D malloc/free: in use at exit: 876 bytes in 6 blocks.
=3D=3D7986=3D=3D malloc/free: 6 allocs, 0 frees, 876 bytes allocated.
=3D=3D7986=3D=3D For counts of detected errors, rerun with: -v
=3D=3D7986=3D=3D searching for pointers to 6 not-freed blocks.
=3D=3D7986=3D=3D checked 10,556,108 bytes.
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D 19 bytes in 1 blocks are still reachable in loss record =
1 of 6
=3D=3D7986=3D=3D at 0x401A639: malloc (vg_replace_malloc.c:149)
=3D=3D7986=3D=3D by 0x400957E: _dl_new_object (dl-object.c:112)
=3D=3D7986=3D=3D by 0x4005CF4: _dl_map_object_from_fd (dl-load.c:880)
=3D=3D7986=3D=3D by 0x4004A32: _dl_map_object (dl-load.c:1950)
=3D=3D7986=3D=3D by 0x414CF5E: dl_open_worker (dl-open.c:229)
=3D=3D7986=3D=3D by 0x400C047: _dl_catch_error (dl-error.c:162)
=3D=3D7986=3D=3D by 0x414CDC3: _dl_open (dl-open.c:514)
=3D=3D7986=3D=3D by 0x414EB22: do_dlopen (dl-libc.c:80)
=3D=3D7986=3D=3D by 0x400C047: _dl_catch_error (dl-error.c:162)
=3D=3D7986=3D=3D by 0x414E9E4: __libc_dlopen_mode (dl-libc.c:42)
=3D=3D7986=3D=3D by 0x4046D33: pthread_cancel_init =
(unwind-forcedunwind.c:42)
=3D=3D7986=3D=3D by 0x4046E83: _Unwind_ForcedUnwind =
(unwind-forcedunwind.c:87)
=3D=3D7986=3D=3D by 0x4045276: __pthread_unwind (unwind.c:130)
=3D=3D7986=3D=3D by 0x4041B21: pthread_exit (pthreadP.h:149)
=3D=3D7986=3D=3D by 0x804844E: thread1 (in /root/test_thread)
=3D=3D7986=3D=3D by 0x4040D59: start_thread (pthread_create.c:259)
=3D=3D7986=3D=3D by 0x41203B9: clone (clone.S:102)
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D 19 bytes in 1 blocks are still reachable in loss record =
2 of 6
=3D=3D7986=3D=3D at 0x401A639: malloc (vg_replace_malloc.c:149)
=3D=3D7986=3D=3D by 0x4004E9F: _dl_map_object (dl-load.c:149)
=3D=3D7986=3D=3D by 0x414CF5E: dl_open_worker (dl-open.c:229)
=3D=3D7986=3D=3D by 0x400C047: _dl_catch_error (dl-error.c:162)
=3D=3D7986=3D=3D by 0x414CDC3: _dl_open (dl-open.c:514)
=3D=3D7986=3D=3D by 0x414EB22: do_dlopen (dl-libc.c:80)
=3D=3D7986=3D=3D by 0x400C047: _dl_catch_error (dl-error.c:162)
=3D=3D7986=3D=3D by 0x414E9E4: __libc_dlopen_mode (dl-libc.c:42)
=3D=3D7986=3D=3D by 0x4046D33: pthread_cancel_init =
(unwind-forcedunwind.c:42)
=3D=3D7986=3D=3D by 0x4046E83: _Unwind_ForcedUnwind =
(unwind-forcedunwind.c:87)
=3D=3D7986=3D=3D by 0x4045276: __pthread_unwind (unwind.c:130)
=3D=3D7986=3D=3D by 0x4041B21: pthread_exit (pthreadP.h:149)
=3D=3D7986=3D=3D by 0x804844E: thread1 (in /root/test_thread)
=3D=3D7986=3D=3D by 0x4040D59: start_thread (pthread_create.c:259)
=3D=3D7986=3D=3D by 0x41203B9: clone (clone.S:102)
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D 28 bytes in 1 blocks are still reachable in loss record =
3 of 6
=3D=3D7986=3D=3D at 0x401A639: malloc (vg_replace_malloc.c:149)
=3D=3D7986=3D=3D by 0x400B161: _dl_map_object_deps (dl-deps.c:489)
=3D=3D7986=3D=3D by 0x414D190: dl_open_worker (dl-open.c:263)
=3D=3D7986=3D=3D by 0x400C047: _dl_catch_error (dl-error.c:162)
=3D=3D7986=3D=3D by 0x414CDC3: _dl_open (dl-open.c:514)
=3D=3D7986=3D=3D by 0x414EB22: do_dlopen (dl-libc.c:80)
=3D=3D7986=3D=3D by 0x400C047: _dl_catch_error (dl-error.c:162)
=3D=3D7986=3D=3D by 0x414E9E4: __libc_dlopen_mode (dl-libc.c:42)
=3D=3D7986=3D=3D by 0x4046D33: pthread_cancel_init =
(unwind-forcedunwind.c:42)
=3D=3D7986=3D=3D by 0x4046E83: _Unwind_ForcedUnwind =
(unwind-forcedunwind.c:87)
=3D=3D7986=3D=3D by 0x4045276: __pthread_unwind (unwind.c:130)
=3D=3D7986=3D=3D by 0x4041B21: pthread_exit (pthreadP.h:149)
=3D=3D7986=3D=3D by 0x804844E: thread1 (in /root/test_thread)
=3D=3D7986=3D=3D by 0x4040D59: start_thread (pthread_create.c:259)
=3D=3D7986=3D=3D by 0x41203B9: clone (clone.S:102)
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D 68 bytes in 1 blocks are possibly lost in loss record 4 =
of 6
=3D=3D7986=3D=3D at 0x401B911: calloc (vg_replace_malloc.c:279)
=3D=3D7986=3D=3D by 0x400E39B: _dl_allocate_tls (dl-tls.c:303)
=3D=3D7986=3D=3D by 0x40412B6: allocate_stack (allocatestack.c:491)
=3D=3D7986=3D=3D by 0x4040E3E: pthread_create@@GLIBC_2.1 =
(pthread_create.c:358)
=3D=3D7986=3D=3D by 0x804846F: main (in /root/test_thread)
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D 160 bytes in 1 blocks are still reachable in loss =
record 5 of 6
=3D=3D7986=3D=3D at 0x401B911: calloc (vg_replace_malloc.c:279)
=3D=3D7986=3D=3D by 0x400CE61: _dl_check_map_versions =
(dl-version.c:299)
=3D=3D7986=3D=3D by 0x414D760: dl_open_worker (dl-open.c:268)
=3D=3D7986=3D=3D by 0x400C047: _dl_catch_error (dl-error.c:162)
=3D=3D7986=3D=3D by 0x414CDC3: _dl_open (dl-open.c:514)
=3D=3D7986=3D=3D by 0x414EB22: do_dlopen (dl-libc.c:80)
=3D=3D7986=3D=3D by 0x400C047: _dl_catch_error (dl-error.c:162)
=3D=3D7986=3D=3D by 0x414E9E4: __libc_dlopen_mode (dl-libc.c:42)
=3D=3D7986=3D=3D by 0x4046D33: pthread_cancel_init =
(unwind-forcedunwind.c:42)
=3D=3D7986=3D=3D by 0x4046E83: _Unwind_ForcedUnwind =
(unwind-forcedunwind.c:87)
=3D=3D7986=3D=3D by 0x4045276: __pthread_unwind (unwind.c:130)
=3D=3D7986=3D=3D by 0x4041B21: pthread_exit (pthreadP.h:149)
=3D=3D7986=3D=3D by 0x804844E: thread1 (in /root/test_thread)
=3D=3D7986=3D=3D by 0x4040D59: start_thread (pthread_create.c:259)
=3D=3D7986=3D=3D by 0x41203B9: clone (clone.S:102)
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D 582 bytes in 1 blocks are still reachable in loss =
record 6 of 6
=3D=3D7986=3D=3D at 0x401B911: calloc (vg_replace_malloc.c:279)
=3D=3D7986=3D=3D by 0x400938E: _dl_new_object (dl-object.c:43)
=3D=3D7986=3D=3D by 0x4005CF4: _dl_map_object_from_fd (dl-load.c:880)
=3D=3D7986=3D=3D by 0x4004A32: _dl_map_object (dl-load.c:1950)
=3D=3D7986=3D=3D by 0x414CF5E: dl_open_worker (dl-open.c:229)
=3D=3D7986=3D=3D by 0x400C047: _dl_catch_error (dl-error.c:162)
=3D=3D7986=3D=3D by 0x414CDC3: _dl_open (dl-open.c:514)
=3D=3D7986=3D=3D by 0x414EB22: do_dlopen (dl-libc.c:80)
=3D=3D7986=3D=3D by 0x400C047: _dl_catch_error (dl-error.c:162)
=3D=3D7986=3D=3D by 0x414E9E4: __libc_dlopen_mode (dl-libc.c:42)
=3D=3D7986=3D=3D by 0x4046D33: pthread_cancel_init =
(unwind-forcedunwind.c:42)
=3D=3D7986=3D=3D by 0x4046E83: _Unwind_ForcedUnwind =
(unwind-forcedunwind.c:87)
=3D=3D7986=3D=3D by 0x4045276: __pthread_unwind (unwind.c:130)
=3D=3D7986=3D=3D by 0x4041B21: pthread_exit (pthreadP.h:149)
=3D=3D7986=3D=3D by 0x804844E: thread1 (in /root/test_thread)
=3D=3D7986=3D=3D by 0x4040D59: start_thread (pthread_create.c:259)
=3D=3D7986=3D=3D by 0x41203B9: clone (clone.S:102)
=3D=3D7986=3D=3D=20
=3D=3D7986=3D=3D LEAK SUMMARY:
=3D=3D7986=3D=3D definitely lost: 0 bytes in 0 blocks.
=3D=3D7986=3D=3D possibly lost: 68 bytes in 1 blocks.
=3D=3D7986=3D=3D still reachable: 808 bytes in 5 blocks.
=3D=3D7986=3D=3D suppressed: 0 bytes in 0 blocks.
|
|
From: Christoph B. <bar...@or...> - 2006-09-01 08:49:03
|
Am Freitag, 1. September 2006 06:17 schrieb kei...@te...:
> Hi.
...
> Can this leak report be safely suppressed?
I guess yes.
But besides that your programm has a severe bug. I wonder that it does not
crash. This is a corrected main:
int main()
{
pthread_t tid;
if (0 == pthread_create(&tid, NULL, thread1, 0))
pthread_join(tid, 0);
return 0;
}
Christoph
|
|
From: Keishi S. <kei...@te...> - 2006-09-03 23:25:12
|
> > Hi.
> ...
> > Can this leak report be safely suppressed?
>
> I guess yes.
This leak report is still seen in Valgrind-3.2.0.
Is this going to be fixed in the future release?
>
> But besides that your programm has a severe bug. I wonder that it does not
> crash. This is a corrected main:
>
> int main()
> {
> pthread_t tid;
>
> if (0 == pthread_create(&tid, NULL, thread1, 0))
> pthread_join(tid, 0);
>
> return 0;
> }
Could you tell me what the bug is?
I cannot think of anything wrong with my code.
"gcc -g -o test_thread test_thread.c -Wall -lpthrad" doesn't
show any warnings.
Thanks for your time.
Keishi
|
|
From: Igmar P. <mai...@jd...> - 2006-09-04 06:28:20
|
> > int main()
> > {
> > pthread_t tid;
> >
> > if (0 == pthread_create(&tid, NULL, thread1, 0))
> > pthread_join(tid, 0);
> >
> > return 0;
> > }
> Could you tell me what the bug is?
The first argument to pthread_create is a pointer to a pthread_t, not the
pthread itself.
> I cannot think of anything wrong with my code.
> "gcc -g -o test_thread test_thread.c -Wall -lpthrad" doesn't
> show any warnings.
Remove the typecast :
xx.c:15: warning: passing arg 1 of `pthread_create' makes pointer from
integer without a cast
Igmar
|
|
From: Christoph B. <bar...@or...> - 2006-09-04 07:42:49
|
> Could you tell me what the bug is?
> I cannot think of anything wrong with my code.
> "gcc -g -o test_thread test_thread.c -Wall -lpthrad" doesn't
> show any warnings.
Your code is:
int main()
{
int tid;
if (0 == pthread_create((pthread_t *)tid, NULL, thread1, 0))
pthread_join(tid, 0);
return 0;
}
You cast an int to a pointer and pass it to pthread_create. pthread_create
tries to dereference the pointer and writes the thread id into the location.
But the pointer you have given is a random uninitialized integer.
Most of the time this should lead to a SIGSEGV.
Christoph
|