This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tsan] Small bugfix
On Sat, Dec 01, 2012 at 04:55:35PM +0400, Dmitry Vyukov wrote:
> > No idea what do you mean by thread leak. What exactly is leaking?
>
>
> Thread leak is joinable but not joined thread.
> I have a pending todo to aggregate them by stack, so in this case it
> will "3 threads leaked here". Perhaps I need to report only finished
> threads, if a thread runs during exit, perhaps it does not matter.
> And there is a flag to disable it at all:
> TSAN_OPTIONS="report_thread_leaks=0" ./app
Actually, seems tsan was right about this, when tweaking the test from 2 to
5 threads I ended up with:
int
main (void)
{
pthread_t p[2]; // wrong, should have been p[5]
int i;
for (i = 0; i < 5; i++)
if (pthread_create (&p[i], NULL, tf, NULL))
return 0;
for (i = 0; i < 5; i++)
pthread_join (p[i], NULL);
return 0;
}
and gcc when optimizing kept the first loop to iterate 5 times
(just taking address of past the end of buffer, undefined too),
while the second loop got optimized into just two iterations (cunrolli
opt).
Jakub