DynamoRIO / DynamoRIO/dynamorio

!HAVE_TLS causes debug builds to fail

Open
#131 0 comments 0 reactions 0 assignees View on GitHub
Migrated Priority-Medium
Dominant language
C
Stars
3.2k
Forks
629
Avg merge
2d 15h
Merged PRs (30d)
31

Description

_From [bharath....@gmail.com](https://code.google.com/u/100705261247615317067/) on April 22, 2009 12:38:23_

What steps will reproduce the problem? Run any app that forks with a debug build of DR compiled with !HAVE_TLS. What is the expected output? What do you see instead? Instead of regular fork behavior the following tend to happen.
1. ASSERT(dcontext == get_thread_private_dcontext()) triggers. If ignored,
2. KSTAT_DC(thread_measured) in kstats_thread_exit() fails assert about
inconsistent TOS for kstats stack.

Both of them are caused by the fact that get_thread_private_dcontext()
returns NULL in the child process when it enters dispatch() post_syscall
(i.e., post fork). This is because the tid used to lookup tls_table is the
child's but the value in the table is still the parent's. This is fixed in
replace_thread_tid() called in post_system_call() for fork. So beginning
in dispatch post syscall till replace_thread_tid()
get_thread_private_dcontext() returns NULL. This affects the assert
mentioned above and kstats. In addition it affects a log of logging
(opening log files, writing to them, dumping core, etc.).

We have 2 choices, fix all the failure points to not depend upon dcontext,
i.e., TLS or fix !HAVE_TLS to get tid fixed in tls_table either in
post_syscall stub or on entry in dispatch().

Till then the work around is to ignore this assert and turn of kstats.

_Original issue: http://code.google.com/p/dynamorio/issues/detail?id=131_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.