Hi,
> There may be a bug in valgrind 3.1.0 which has been fixed; the current
> release is 3.11.0. Can you compile or download binaries for version 3.11.0?
I tried Valgrind 3.10.0 and get the same error as with 3.1.0
> If it still fails (or if you can't use a copy of 3.11.0), the next step is
> to try to reduce the problem to a program small enough to post to the list.
[...]
Ok. This is short version of my program.
> #define _GNU_SOURCE
> #include <fcntl.h>
> #include <sys/stat.h>
> #include <semaphore.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <sched.h>
>
> #define STACK_SIZE 8*1024*1024
>
>
> int at_wait(void* a) {
> sem_t* _sem = sem_open("test", O_CREAT, S_IRWXU, 1);
>
> printf("2 - waiting\n");
> fflush(stdout);
> sem_wait(_sem);
> printf("2 - i am free. Tralalaaa\n");
> fflush(stdout);
>
> sem_close(_sem);
> return 0;
> }
>
>
> int main() {
> sem_t* sem = sem_open("test", O_CREAT, S_IRWXU, 1);
> void* stack = malloc(STACK_SIZE);
>
> sem_wait(sem);
> if(-1 == clone(at_wait, stack + STACK_SIZE, 0, NULL)) {
> fputs("Cannot clone program :(\n", stderr);
> exit(EXIT_FAILURE);
> }
>
> sleep(2);
> sem_post(sem);
> printf("1 - OK\n");
>
> int status;
> int _pid = waitpid(-1, &status, __WCLONE);
> if(_pid == -1) {
> fputs("waitpid error\n", stderr);
> exit(EXIT_FAILURE);
> }
> if(_pid > 0) {
> if(WIFEXITED(status)) {
> printf("child exited - %i\n", _pid);
> }
> }
>
> sem_close(sem);
> sem_unlink("test");
> free(stack);
> printf("program end\n");
>
> return 0;
> }
If i compile this with
gcc -gdwarf-2 main.c -lpthread
or
gcc main.c -lpthread
and run
valgrind --tool=helgrind ./a.out
I get the error
--- dump start ---
==7032== Helgrind, a thread error detector
==7032== Copyright (C) 2007-2013, and GNU GPL'd, by OpenWorks LLP et al.
==7032== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==7032== Command: ./a.out
==7032==
==7033==
==7033== Process terminating with default action of signal 11 (SIGSEGV)
==7033== Access not within mapped region at address 0xFFFFFFFFFFFFFFF8
==7033== at 0x400B6B: main (main.c:39)
==7033== If you believe this happened as a result of a stack
==7033== overflow in your program's main thread (unlikely but
==7033== possible), you can try to increase the size of the
==7033== main thread stack using the --main-stacksize= flag.
==7033== The main thread stack size used in this run was 8388608.
==7033==
==7033== For counts of detected and suppressed errors, rerun with: -v
==7033== Use --history-level=approx or =none to gain increased speed, at
==7033== the cost of reduced accuracy of conflicting-access information
==7033== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
1 - OK
program end
==7032==
==7032== For counts of detected and suppressed errors, rerun with: -v
==7032== Use --history-level=approx or =none to gain increased speed, at
==7032== the cost of reduced accuracy of conflicting-access information
==7032== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
--- dump end ---
What's wrong? Some bug in my program (which i do not see) or problem
with valgrind?
Thanks for any help :),
John
------------------------------------------------------------------------------
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users