Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

pthread_self: fix odd crashes in user code due to pthread lib being s…

…pooked by incorrect (too late) init
  • Loading branch information...
commit ca09e4d4bfe402bcf3f4ec6bb05fa64a6ea17db3 1 parent b7bbdd4
Ger Hobbelt authored
2  create.c
View
@@ -285,7 +285,6 @@ pthread_create (pthread_t * tid,
FAIL0:
if (result != 0)
{
-
ptw32_threadDestroy (thread);
tp = NULL;
@@ -304,5 +303,4 @@ pthread_create (pthread_t * tid,
pthread_count++;
#endif
return (result);
-
} /* pthread_create */
1  pthread_exit.c
View
@@ -102,5 +102,4 @@ pthread_exit (void *value_ptr)
ptw32_throw (PTW32_EPS_EXIT);
/* Never reached. */
-
}
4 pthread_self.c
View
@@ -63,6 +63,9 @@ pthread_self (void)
pthread_t nil = {NULL, 0};
ptw32_thread_t * sp;
+ if (!ptw32_processInitialize())
+ return nil;
+
#if defined(_UWIN)
if (!ptw32_selfThreadKey)
return nil;
@@ -138,5 +141,4 @@ pthread_self (void)
}
return (self);
-
} /* pthread_self */
5 ptw32_new.c
View
@@ -85,10 +85,13 @@ ptw32_new (void)
if (tp->cancelEvent == NULL)
{
+ int err = GetLastError();
+ char buf[80];
+ sprintf(buf, "error = %08x\n", err);
+
ptw32_threadReusePush (tp->ptHandle);
return nil;
}
return t;
-
}
2  ptw32_processInitialize.c
View
@@ -83,10 +83,8 @@ ptw32_processInitialize (void)
if ((pthread_key_create (&ptw32_selfThreadKey, NULL) != 0) ||
(pthread_key_create (&ptw32_cleanupKey, NULL) != 0))
{
-
ptw32_processTerminate ();
}
return (ptw32_processInitialized);
-
} /* processInitialize */
10 ptw32_reuse.c
View
@@ -101,7 +101,6 @@ ptw32_threadReusePop (void)
ptw32_mcs_lock_release(&node);
return t;
-
}
/*
@@ -113,12 +112,21 @@ ptw32_threadReusePop (void)
void
ptw32_threadReusePush (pthread_t thread)
{
+pthread_t thread_clone = thread;
+pthread_t thread_clone2;
+
ptw32_thread_t * tp = (ptw32_thread_t *) thread.p;
pthread_t t;
ptw32_mcs_local_node_t node;
+ thread_clone2 = tp->ptHandle;
+
ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node);
+ if (!tp && thread_clone.p == thread_clone2.p)
+ {
+ t.p = 0;
+ }
t = tp->ptHandle;
memset(tp, 0, sizeof(ptw32_thread_t));
1  sem_wait.c
View
@@ -183,5 +183,4 @@ sem_wait (sem_t * sem)
}
return 0;
-
} /* sem_wait */
Please sign in to comment.
Something went wrong with that request. Please try again.