Corrupt Valgrind?

ساخت وبلاگ

Vote count: 0

I have the following simple program:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <assert.h>
#include <errno.h>
#define handle_error_en(en, msg) {do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0);}
#define status_check(stat) ((stat != 0) ? (handle_error_en(stat, "status error")) : ((void)0))
static void* thread_start(void *arg)
{ printf("%sn", "thread working.."); sleep(1); return NULL;
}
int main(int argc, char const *argv[])
{ int status; pthread_t thread; status = pthread_create(&thread, NULL, thread_start, NULL); status_check(status); status = pthread_join(thread, NULL); status_check(status); printf("%sn", "exit program.."); return 0;
}

When I run Valgind with

Valgrind --tool=helgrind ./threads_simple

I get 54 errors, all being data race errors. Just picking one of them:

Possible data race during write of size 4 at 0x1003FD2D8 by thread #1
==17334== Locks held: none
==17334== at 0x1003E2FDF: spin_unlock (in /usr/lib/system/libsystem_platform.dylib)
==17334== by 0x1003F7EAF: pthread_join (in /usr/lib/system/libsystem_pthread.dylib)
==17334== by 0x100000E37: main (threads_simple.c:29)
==17334==
==17334== This conflicts with a previous write of size 4 by thread #2
==17334== Locks held: none
==17334== at 0x1003E2FDF: spin_unlock (in /usr/lib/system/libsystem_platform.dylib)
==17334== by 0x1003F6FD6: _pthread_start (in /usr/lib/system/libsystem_pthread.dylib)
==17334== by 0x1003F43EC: thread_start (in /usr/lib/system/libsystem_pthread.dylib)
==17334== Address 0x1003fd2d8 is in the Data segment of /usr/lib/system/libsystem_pthread.dylib

I have written many more small thread-programms, all give errors like this. Is my Valgrind installation corrupt? I installed it on mac via brew.

asked 24 secs ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : valgrind corrupt memory,valgrind corrupt heap, نویسنده : استخدام کار backsoft بازدید : 401 تاريخ : چهارشنبه 31 شهريور 1395 ساعت: 2:08