Bug 78422 - valgrind's libpthread.so: UNIMPLEMENTED FUNCTION: pthread_mutex_timedlock
Summary: valgrind's libpthread.so: UNIMPLEMENTED FUNCTION: pthread_mutex_timedlock
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 2.1.1
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
: 89592 94369 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-03-25 04:19 UTC by Glenn Maynard
Modified: 2004-12-05 11:57 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch to implement pthread_mutex_timedlock (9.29 KB, patch)
2004-09-25 19:03 UTC, Tom Hughes
Details
Testprogramm for incorrect timing. (956 bytes, text/plain)
2004-09-27 22:58 UTC, Peter Seiderer
Details
Improved patch to implement pthread_mutex_timedlock (11.23 KB, patch)
2004-09-27 23:40 UTC, Peter Seiderer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Glenn Maynard 2004-03-25 04:19:49 UTC
(Actually, Debian unstable; it's missing from the platform list.)

10:14pm glenn@zewt/2 [~/stepmania] valgrind ./stepmania
==24866== Memcheck, a memory error detector for x86-linux.
==24866== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward.
==24866== Using valgrind-2.1.1, a program supervision framework for x86-linux.
==24866== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward.
==24866== For more details, rerun with: -v
==24866==
==24866== valgrind's libpthread.so: UNIMPLEMENTED FUNCTION: 
pthread_mutex_timedlock
==24866==
valgrind's libpthread.so: unimplemented function
Please report this bug at: valgrind.kde.org


==24866== Invalid read of size 4
==24866==    at 0x3C2AF67A: __res_state (vg_libpthread.c:1992)
==24866==    by 0x3C547F0E: res_thread_freeres (res_init.c:572)
==24866==    by 0x3C547B84: __GI___libc_freeres (set-freeres.c:49)
==24866==    by 0x3C01AB9E: __vgInject___libc_freeres_wrapper 
(vg_intercept.c:77)
==24866==  Address 0x0 is not stack'd, malloc'd or free'd
==24866==
==24866== Process terminating with default action of signal 11 (SIGSEGV): 
dumping core
==24866==  Access not within mapped region at address 0x0
==24866==    at 0x3C2AF67A: __res_state (vg_libpthread.c:1992)
==24866==    by 0x3C547F0E: res_thread_freeres (res_init.c:572)
==24866==    by 0x3C547B84: __GI___libc_freeres (set-freeres.c:49)
==24866==    by 0x3C01AB9E: __vgInject___libc_freeres_wrapper 
(vg_intercept.c:77)
==24866==
==24866== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 61 from 1)
==24866== malloc/free: in use at exit: 667043 bytes in 22 blocks.
==24866== malloc/free: 22 allocs, 0 frees, 667043 bytes allocated.
==24866== For a detailed leak analysis,  rerun with: --leak-check=yes
==24866== For counts of detected errors, rerun with: -v
zsh: 24866 segmentation fault  valgrind ./stepmania
Comment 1 Tom Hughes 2004-09-25 12:50:50 UTC
*** Bug 89592 has been marked as a duplicate of this bug. ***
Comment 2 Tom Hughes 2004-09-25 19:03:55 UTC
Created attachment 7678 [details]
Patch to implement pthread_mutex_timedlock

This patch implemented pthread_mutex_timedlock in valgrind's pthreads library.
Comment 3 Wouter Cloetens 2004-09-27 15:31:20 UTC
I tried the patch against CVS HEAD, and it looks like I'm getting a timeout on every call to pthread_mutex_timedlock() when in fact the lock should succeed without delay. 
Comment 4 Tom Hughes 2004-09-27 19:17:05 UTC
It seems to work fine for me - can you construct a simple test case? or post the output of valgrind when run with --trace-pthread=all --trace-sched=yes?
Comment 5 Peter Seiderer 2004-09-27 22:58:20 UTC
Created attachment 7698 [details]
Testprogramm for incorrect timing.

The calculation of ms_end is incorrect (for huge timeouts there is
a overflow). The same as in bug 76845
(http://bugs.kde.org/show_bug.cgi?id=76845) with pthread_cond_timedwait().

Or use the attached testprogramm with the following commandline
(should give a timeout of 4294968 seconds):

time valgrind --tool=none ./a.out 4294968 100
==7193== Nulgrind, a binary JIT-compiler for x86-linux.
==7193== Copyright (C) 2002-2004, and GNU GPL'd, by Nicholas Nethercote.
==7193== Using valgrind-2.3.0.CVS, a program supervision framework for
x86-linux.
==7193== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward et al.
==7193== For more details, rerun with: -v
==7193== 
==7193== 

real	0m0.904s
user	0m0.160s
sys	0m0.000s
Comment 6 Peter Seiderer 2004-09-27 23:40:42 UTC
Created attachment 7700 [details]
Improved patch to implement pthread_mutex_timedlock

Improved Tom Hughes previous patch:
- fix timeout calculation (according to patch for bug 76845)
- fix delta calculation in vg_scheduler.c (according to patch for bug 76845)
Comment 7 Tom Hughes 2004-09-27 23:43:30 UTC
Thanks, but I'd rather not confuse this bug by bringing the issue of long timeouts into it - that is still pending further review by Jeremy if I'm reading the other bug correctly.
Comment 8 Tom Hughes 2004-10-17 17:02:10 UTC
There has been no more feedback regarding this patch and it seems to work for me so I have committed my original patch. If anybody does find a problem with it timing out when it shouldn't then please open a new bug.

As far as the long timeout issue goes I'm going to go and have a look at that bug now and see what I can do about commiting a fix for both condition variables and mutexes.
Comment 9 Tom Hughes 2004-12-05 11:57:40 UTC
*** Bug 94369 has been marked as a duplicate of this bug. ***