Permalink
Browse files

Fix terrible bug in thread trampoline

New threads created while the coroutine library is loaded have a pretty
good chance of getting corrupted it seems. eio threading hasn't been
put through too much scrutiny unfortunately, so I didn't catch this
until now.
  • Loading branch information...
1 parent ac01c73 commit ab873954b0cf8a3b9c8a93d1f84989f489231edf @laverdet committed Feb 18, 2011
Showing with 2 additions and 3 deletions.
  1. +1 −1 package.json
  2. +1 −2 src/coroutine.cc
View
@@ -1,6 +1,6 @@
{
"name": "fibers",
- "version": "0.1.4",
+ "version": "0.1.5",
"description": "Cooperative multi-tasking for Javascript; or, the closest thing to a thread you'll see in node",
"keywords": ["fiber", "fibers", "coroutine", "thread", "async", "parallel", "worker"],
"homepage": "https://github.com/laverdet/node-fibers",
View
@@ -323,9 +323,8 @@ int pthread_key_create(pthread_key_t* key, pthread_dtor_t dtor) {
void thread_trampoline(void** args_vector) {
void* (*entry)(void*) = (void*(*)(void*))args_vector[0];
void* arg = args_vector[1];
- Thread& thread = *static_cast<Thread*>(args_vector[1]);
+ Thread& thread = *static_cast<Thread*>(args_vector[2]);
delete[] args_vector;
- thread.handle = o_pthread_self();
o_pthread_setspecific(thread_key, &thread);
entry(arg);
}

0 comments on commit ab87395

Please sign in to comment.