Re: Improve hackbench

Ingo Molnar
2008-01-04T13:01:52Z

* Török Edwin <edwintorok@gmail.com> wrote:

> On x86-64 there's a bug [*], that causes hackbench to segfault when
> compiled with optimizations:
> in reap_worker():
> int status;
> ...
> pthread_join(id, (void **)(void *)&status);
>
> That is not correct, sizeof(void*) > sizeof(int) on x86-64.
> Something gets overwritten on the stack, I tried with gcc
> -fstack-protector, but it doesn't detect it !?
> After applying the patch, it no longer segfaults.
>
> This patch fixes it:
> --- hackbench.c 2008-01-04 10:08:26.000000000 +0200
> +++ ../hackbench.c 2008-01-04 13:45:22.000000000 +0200
> @@ -241,8 +241,10 @@
> wait(&status);
> if (!WIFEXITED(status))
> exit(1);
> - } else
> - pthread_join(id, (void **)(void *)&status);
> + } else {
> + void* status;
> + pthread_join(id, (void **)&status);
> + }
> }

thanks, applied & updated the file.

Ingo