Don't you love it when clang test suite fails because of pthread_create bad address or something and the stack trace points to glibc :akkoderp:

So it's like is clang breaking (scary) or it's glibc (scarier)

Though it only happens with clang-built-clang (and not with gcc-built-clang) so my guess is that it's clang that is broken but

Okay it seems to not happen when I set LIBCLANG_NOTHREADS so probably something happens during thread creation

Also, if I single-step through it with gdb then the problem's gone...

But it still happens if I just press continue through all the breakpoints

So, race condition?

So setting a breakpoint *just* before the instruction that traps to the kernel to do clone(2) seems to slow things down enough that the testcase succeeds, so now I strongly believe that this is indeed a race

Now the question is, how do I track this down :notlikemiya:

So what I do know as of now is that the failing test `c-index-test -test-annotate-tokens` is structured like this:

main
-> spawn outerWorker
----> spawn innerWorker
----> join innerWorker
-> joinOuterWorker

The crash happens when it was about to start the inner worker, but that's pretty much all I know as of now

Oh and the test provides control over which threads are spawned; if I tune it so that it only spawn one level of workers, instead of two, it works, regardless of which spawning is disabled

@robryk Nothing died, it's more like either `pthread_create` or `pthread_attr_setstacksize` failed and then the entire program just noped out upon getting the return value

The chain is like:
`main` in c-index-test.c -> pthread_create `thread_runner` -> pthread_create `ParseTranslationUnitImpl`

It's the creation of ParseTranslationUnitImpl that fails
If I replaced the `pthread_create`s with a plain function call, then everything would work flawlessly

@robryk
> either `pthread_create` or `pthread_attr_setstacksize` failed

This is the fun part: I said this because the error message and gdb disagrees about what function failed; the error message says something like "LIBCLANG FATAL ERROR: pthread_create failed: Bad address", but gdb's backtrace points to `pthread_attr_setstacksize` as the source of failure

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.