My favorites | Sign in
Project Home Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 2136: Race condition in thread exit+join can exhaust TLS indexes
1 person starred this issue and may be notified of changes. Back to list
Status:  Available
Owner:  ----
Cc:  s...@google.com


Sign in to add a comment
 
Project Member Reported by mseaborn@chromium.org, Aug 5, 2011
This is a very similar problem to issue 1027.

Suppose we have a test program which repeatedly creates a thread and pthread_join()s it.

Suppose I insert a sleep into NaClSysCommonThreadSuicide() before NaClAppThreadDtor().

Then the test program will fail after 8192 threads (even on x86-64):

...
creating thread 8190
creating thread 8191
[9474,2411669248:10:12:05.050861] NaClAllocateThreadIdx: no more slots for a thread
[9474,2411669248:10:12:05.050890] NaClTlsAllocate: no more slots for a thread
[9474,2411669248:10:12:05.050899] No tls for thread, num_thread 1
[9474,2411669248:10:12:05.050908] NaClCreateAdditionalThread: could not allocate thread index.  Returning EAGAIN per POSIX specs.

The problem is that the untrusted pthread_join() returns before the trusted NaClAppThread is freed and NaClTlsFree() is called.

Part of the problem is that NaClCommonSysThreadExit() marks the untrusted thread as exited before NaClTlsFree() is called.  Due to differences in the nacl-newlib/nacl-glibc pthread implementations, this matters with nacl-glibc but not nacl-newlib.

We could address this by reordering the thread exit code, but I think it's better to fix all the exit/join race conditions by implementing syscalls for joinable threads (see issue 1027).

Aug 5, 2011
Project Member #1 mseaborn@chromium.org
(No comment was entered for this change.)
Labels: ThreadJoinRace
Aug 19, 2011
Project Member #2 cstefan...@google.com
(No comment was entered for this change.)
Status: Assigned
Labels: Mstone-15
Jul 17, 2013
Project Member #3 mseaborn@chromium.org
(No comment was entered for this change.)
Status: Available
Owner: ---
Labels: -Pri-2 -Mstone-15 Pri-3
Sign in to add a comment

Powered by Google Project Hosting