|
From: Christoph B. <bar...@or...> - 2006-09-04 07:42:49
|
> Could you tell me what the bug is?
> I cannot think of anything wrong with my code.
> "gcc -g -o test_thread test_thread.c -Wall -lpthrad" doesn't
> show any warnings.
Your code is:
int main()
{
int tid;
if (0 == pthread_create((pthread_t *)tid, NULL, thread1, 0))
pthread_join(tid, 0);
return 0;
}
You cast an int to a pointer and pass it to pthread_create. pthread_create
tries to dereference the pointer and writes the thread id into the location.
But the pointer you have given is a random uninitialized integer.
Most of the time this should lead to a SIGSEGV.
Christoph
|