The attached testcase (which is simply pthread_cond_init + 
pthread_cond_destroy), leads to an error in helgrind:
"pthread_cond_destroy: destruction of unknown cond var"

I've seen this forever with helgrind, but it's time to clean this up :)

However my debugging got stuck. I found out that 1) the call is given a valid 
condition variable pointer, and it actually succeeds, outside and inside 
helgrind. 2) the error message comes from this line of code:

    DO_CREQ_v_W(_VG_USERREQ__HG_PTHREAD_COND_DESTROY_PRE,
                pthread_cond_t*,cond);

(hg_intercepts.c:940).
How do I debug this further? This looks like a hook to me, the actual call is 
the next line,  CALL_FN_W_W(ret, fn, cond), isn't it?

Output from helgrind (with debug output added by me)

==4741== Helgrind, a thread error detector
==4741== Copyright (C) 2007-2012, and GNU GPL'd, by OpenWorks LLP et al.
==4741== Using Valgrind-3.9.0.SVN and LibVEX; rerun with -h for copyright info
==4741== Command: ./bin/testcase_pthread_cond
==4741== 
pthread_cond_init(0xffefff390) said 0
cond = 0xffefff390
==4741== ---Thread-Announcement------------------------------------------
==4741== 
==4741== Thread #1 is the program's root thread
==4741== 
==4741== ----------------------------------------------------------------
==4741== 
==4741== Thread #1: pthread_cond_destroy: destruction of unknown cond var
==4741==    at 0x4C2EB28: pthread_cond_destroy_WRK (hg_intercepts.c:940)
==4741==    by 0x4C2FA44: pthread_cond_destroy@* (hg_intercepts.c:958)
==4741==    by 0x400AFC: main (testcase_pthread_cond.cpp:21)
==4741== 
pthread_cond_destroy 0xffefff390 in helgrind, AFTER DO_ and before CALL_
pthread_cond_destroy(0xffefff390) said 0


-- 
David Faure, [email protected], http://www.davidfaure.fr
Working on KDE, in particular KDE Frameworks 5
#include <pthread.h>
#include <stdio.h>

// Modelled after QWaitCondition, to debug helgrind's "pthread_cond_destroy: destruction of unknown cond var"

void qt_initialize_pthread_cond(pthread_cond_t *cond)
{
    pthread_condattr_t condattr;
    pthread_condattr_init(&condattr);
    int ok = pthread_cond_init(cond, &condattr);
    fprintf(stderr, "pthread_cond_init(%p) said %d\n", cond, ok);
    pthread_condattr_destroy(&condattr);
}

int main( int argc, char** argv ) {
    pthread_cond_t cond;
    qt_initialize_pthread_cond(&cond);
    fprintf(stderr, "cond = %p\n", &cond);
    int ok = pthread_cond_destroy(&cond);
    fprintf(stderr, "pthread_cond_destroy(%p) said %d\n", &cond, ok);
    return 0;
}

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to