[uClibc] pthread_cond_timedwait() segfault
Alexandre Carmel-Veilleux
saruman at northernhacking.org
Sun Apr 18 02:38:04 UTC 2004
Hello,
I'm trying to run a threaded application on the Linksys WRT54G.
The OpenWRT's project uses uClibc-20040331 as libc. The program uses
pthread_cond_timedwait() and segfaults. The target is really tight in
flash space and strace(1) yields nothing.
I'm hoping someone with a bit more knowledge about the ins and
outs of uClibc could take a look at it. I've included a test application
that will reliably segfault in uClibc but run perfectly fine under a
normal debian or OS X box.
Thanks,
Alex
-------------- next part --------------
#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
#include <pthread.h>
void thread(void *);
int
main(int argc, char **argv)
{
pthread_t tid;
int i;
pthread_create(&tid, NULL, (void *)thread, NULL);
pthread_detach(tid);
while (1) {
fprintf(stderr, "Long loop...");
for (i = 0; i < 200000000; i++);
}
}
void
thread(void *ptr)
{
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
struct timespec timeout;
while (1) {
timeout.tv_sec = time(NULL) + 15;
timeout.tv_nsec = 0;
pthread_cond_timedwait(&cond, &mutex, &timeout);
fprintf(stderr, "Thread running\n");
}
}
More information about the uClibc
mailing list