Project: v8 Issues People Development process History Sign in
New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Issue 708 GetCurrentThreadId() returns incorrect id in main thread after creation and termination of another thread.
Starred by 5 users Reported by jeff...@gmail.com, May 15 2010 Back to list
Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Feb 2015
HW: ----
OS: ----
Priority: ----
Type: ----



Sign in to add a comment
The thread id returned by a call to GetCurrentThreadId() in the main thread
changes if another thread is created and then terminated. The main thread
starts with a thread id of 1, and a spawned thread gets a thread id of 2,
but then once the spawned thread exits, a call to GetCurrentThreadId in the
main thread returns 2, not 1. 
 
The following trivial patch seems to fix this problem in at least some cases.  I'm not familiar with the v8 source and haven't checked for any adverse consequences of the patch.


Index: src/api.cc
===================================================================
--- src/api.cc	(revision 5592)
+++ src/api.cc	(working copy)
@@ -4015,7 +4015,7 @@
 int V8::GetCurrentThreadId() {
   API_ENTRY_CHECK("V8::GetCurrentThreadId()");
   EnsureInitialized("V8::GetCurrentThreadId()");
-  return i::Top::thread_id();
+  return i::ThreadManager::CurrentId();
 }

Comment 3 by bgam...@gmail.com, Jul 23 2011
It looks like this patch is no longer applicable so there is a good chance that this issue has been fixed.
Status: Fixed
This update was done during clean-up of the issue tracker.

Seems to be fixed.
Sign in to add a comment