Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite recursion when libpthread.so.0 cannot be dynamically loaded #229

Closed
mbUSC opened this issue Apr 18, 2024 · 0 comments · Fixed by #238
Closed

Infinite recursion when libpthread.so.0 cannot be dynamically loaded #229

mbUSC opened this issue Apr 18, 2024 · 0 comments · Fixed by #238

Comments

@mbUSC
Copy link

mbUSC commented Apr 18, 2024

In get_pthread_handle (real.cpp), dlopen can fail to load "libpthread.so.0" and return a NULL pointer.
This condition is not properly handled by Coz.

How to reproduce the problem:

Build https://github.com/ClickHouse/ClickHouse.
Try profiling the clickhouse_server program with Coz. It fails silently (no output).

Debugging:

Running Coz with strace shows that the child process terminates with SIGSEGV. If you capture a core dump, you can see that there is a stack overflow due to infinite recursion in pthread_cond_broadcast. This is because RTLD_DEFAULT is defined as NULL in include/dlfcn.h, so dlsym interprets the NULL handle passed to it as RTLD_DEFAULT. This causes the lookup for the "real" function to use the default search order, hence returning the overridden symbol from libcoz.so instead of the actual pthreads implementation.

@mbUSC mbUSC changed the title Infinite recursion when libpthread.so.0 cannot be loaded Infinite recursion when libpthread.so.0 cannot be dynamically loaded Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant