mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 18:13:01 +00:00
fix 307082 HG false positive: pthread_cond_destroy: destruction of unknown cond var
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13332
This commit is contained in:
parent
c7f8191472
commit
6ceb0e1f83
1
NEWS
1
NEWS
@ -95,6 +95,7 @@ m = merged into 3_8_BRANCH
|
||||
|
||||
307038 DWARF2 CFI reader: unhandled DW_OP_ opcode 0x8 (DW_OP_const1u et al)
|
||||
FIXED r13010
|
||||
307082 [390] HG false positive: pthread_cond_destroy: destruction of unknown cond var
|
||||
|
||||
307101 sys_capget second argument can be NULL
|
||||
FIXED r13021
|
||||
|
||||
@ -115,7 +115,8 @@ typedef
|
||||
_VG_USERREQ__HG_ARANGE_MAKE_UNTRACKED, /* Addr a, ulong len */
|
||||
_VG_USERREQ__HG_ARANGE_MAKE_TRACKED, /* Addr a, ulong len */
|
||||
_VG_USERREQ__HG_PTHREAD_BARRIER_RESIZE_PRE, /* pth_bar_t*, ulong */
|
||||
_VG_USERREQ__HG_CLEAN_MEMORY_HEAPBLOCK /* Addr start_of_block */
|
||||
_VG_USERREQ__HG_CLEAN_MEMORY_HEAPBLOCK, /* Addr start_of_block */
|
||||
_VG_USERREQ__HG_PTHREAD_COND_INIT_POST /* pth_cond_t*, pth_cond_attr_t*/
|
||||
|
||||
} Vg_TCheckClientRequest;
|
||||
|
||||
|
||||
@ -631,10 +631,8 @@ PTH_FUNC(int, pthreadZumutexZuunlock, // pthread_mutex_unlock
|
||||
|
||||
/* Handled: pthread_cond_wait pthread_cond_timedwait
|
||||
pthread_cond_signal pthread_cond_broadcast
|
||||
pthread_cond_init
|
||||
pthread_cond_destroy
|
||||
|
||||
Unhandled: pthread_cond_init
|
||||
-- is this important?
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------
|
||||
@ -917,6 +915,55 @@ static int pthread_cond_broadcast_WRK(pthread_cond_t* cond)
|
||||
# error "Unsupported OS"
|
||||
#endif
|
||||
|
||||
// glibc: pthread_cond_init@GLIBC_2.0
|
||||
// glibc: pthread_cond_init@GLIBC_2.2.5
|
||||
// glibc: pthread_cond_init@@GLIBC_2.3.2
|
||||
// darwin: pthread_cond_init
|
||||
// Easy way out: Handling of attr could have been messier.
|
||||
// It turns out that pthread_cond_init under linux ignores
|
||||
// all information in cond_attr, so do we.
|
||||
// FIXME: MacOS X?
|
||||
__attribute__((noinline))
|
||||
static int pthread_cond_init_WRK(pthread_cond_t* cond, pthread_condattr_t *cond_attr)
|
||||
{
|
||||
int ret;
|
||||
OrigFn fn;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
|
||||
if (TRACE_PTH_FNS) {
|
||||
fprintf(stderr, "<< pthread_cond_init %p", cond);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
CALL_FN_W_WW(ret, fn, cond, cond_attr);
|
||||
|
||||
if (ret == 0) {
|
||||
DO_CREQ_v_WW(_VG_USERREQ__HG_PTHREAD_COND_INIT_POST,
|
||||
pthread_cond_t*,cond, pthread_condattr_t*, cond_attr);
|
||||
} else {
|
||||
DO_PthAPIerror( "pthread_cond_init", ret );
|
||||
}
|
||||
|
||||
if (TRACE_PTH_FNS) {
|
||||
fprintf(stderr, " coinit -> %d >>\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#if defined(VGO_linux)
|
||||
PTH_FUNC(int, pthreadZucondZuinitZAZa, // pthread_cond_init@*
|
||||
pthread_cond_t* cond, pthread_condattr_t* cond_attr) {
|
||||
return pthread_cond_init_WRK(cond, cond_attr);
|
||||
}
|
||||
#elif defined(VGO_darwin)
|
||||
PTH_FUNC(int, pthreadZucondZuinit, // pthread_cond_init
|
||||
pthread_cond_t* cond, pthread_condattr_t * cond_attr) {
|
||||
return pthread_cond_init_WRK(cond, cond_attr);
|
||||
}
|
||||
#else
|
||||
# error "Unsupported OS"
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// glibc: pthread_cond_destroy@@GLIBC_2.3.2
|
||||
|
||||
@ -2377,6 +2377,22 @@ static void evh__HG_PTHREAD_COND_WAIT_POST ( ThreadId tid,
|
||||
cvi->nWaiters--;
|
||||
}
|
||||
|
||||
static void evh__HG_PTHREAD_COND_INIT_POST ( ThreadId tid,
|
||||
void* cond, void* cond_attr )
|
||||
{
|
||||
CVInfo* cvi;
|
||||
|
||||
if (SHOW_EVENTS >= 1)
|
||||
VG_(printf)("evh__HG_PTHREAD_COND_INIT_POST"
|
||||
"(ctid=%d, cond=%p, cond_attr=%p)\n",
|
||||
(Int)tid, (void*)cond, (void*) cond_attr );
|
||||
|
||||
cvi = map_cond_to_CVInfo_lookup_or_alloc( cond );
|
||||
tl_assert (cvi);
|
||||
tl_assert (cvi->so);
|
||||
}
|
||||
|
||||
|
||||
static void evh__HG_PTHREAD_COND_DESTROY_PRE ( ThreadId tid,
|
||||
void* cond )
|
||||
{
|
||||
@ -4842,6 +4858,13 @@ Bool hg_handle_client_request ( ThreadId tid, UWord* args, UWord* ret)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Thread successfully completed pthread_cond_init:
|
||||
cond=arg[1], cond_attr=arg[2] */
|
||||
case _VG_USERREQ__HG_PTHREAD_COND_INIT_POST:
|
||||
evh__HG_PTHREAD_COND_INIT_POST( tid,
|
||||
(void*)args[1], (void*)args[2] );
|
||||
break;
|
||||
|
||||
/* cond=arg[1] */
|
||||
case _VG_USERREQ__HG_PTHREAD_COND_DESTROY_PRE:
|
||||
evh__HG_PTHREAD_COND_DESTROY_PRE( tid, (void*)args[1] );
|
||||
|
||||
@ -12,6 +12,7 @@ EXTRA_DIST = \
|
||||
annotate_rwlock.stderr.exp \
|
||||
annotate_smart_pointer.vgtest annotate_smart_pointer.stdout.exp \
|
||||
annotate_smart_pointer.stderr.exp \
|
||||
cond_init_destroy.vgtest cond_init_destroy.stderr.exp \
|
||||
cond_timedwait_invalid.vgtest cond_timedwait_invalid.stdout.exp \
|
||||
cond_timedwait_invalid.stderr.exp \
|
||||
bar_bad.vgtest bar_bad.stdout.exp bar_bad.stderr.exp \
|
||||
@ -101,6 +102,7 @@ EXTRA_DIST = \
|
||||
# should be conditionally compiled like tc20_verifywrap is.
|
||||
check_PROGRAMS = \
|
||||
annotate_hbefore \
|
||||
cond_init_destroy \
|
||||
cond_timedwait_invalid \
|
||||
free_is_write \
|
||||
hg01_all_ok \
|
||||
|
||||
8
helgrind/tests/cond_init_destroy.c
Normal file
8
helgrind/tests/cond_init_destroy.c
Normal file
@ -0,0 +1,8 @@
|
||||
#include <pthread.h>
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
pthread_cond_t c;
|
||||
pthread_cond_init(& c, NULL);
|
||||
pthread_cond_destroy(& c);
|
||||
return 0;
|
||||
}
|
||||
3
helgrind/tests/cond_init_destroy.stderr.exp
Normal file
3
helgrind/tests/cond_init_destroy.stderr.exp
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
|
||||
1
helgrind/tests/cond_init_destroy.vgtest
Normal file
1
helgrind/tests/cond_init_destroy.vgtest
Normal file
@ -0,0 +1 @@
|
||||
prog: cond_init_destroy
|
||||
Loading…
x
Reference in New Issue
Block a user