On Monday 23 March 2009 23:05:34 Sven Eckelmann wrote:
On Monday 23 March 2009 18:13:32 Marek Lindner wrote:
I downloaded the OpenWRT trunk and compiled the i386 image before loading it into a qemu environment. I can confirm that batman does nothing if started without a debug level. It seems the main thread is not doing anything. Interestingly, if I compile & run batman on my debian machine it runs without problems. I guess OpenWRT uses some different libs / compile time options / etc that provoke that problem.
Seems to a different behaviour when doing a fork+pthreads_create... somehow. Try to remove the fork and the setgid from posix/init.c:my_daemon and compile it again (against uclib of course). You should notice that it works without any problems. If you do a static build against a current glibc on i386 (2.7 here) it works as expected. So I would guess a uClibc specific behaviour when calling pthread_create after a fork. The thread (unix_listen) itself runs without any problems but the main thread seems to be blocked at pthread_create( &unix_if.listen_thread_id, NULL, &unix_listen, NULL ); in posix/init.c:apply_init_args.
Forgot to add my minimal testcase:
#include <unistd.h> #include <stdio.h> #include <pthread.h>
void* dummy_thread(void* unused) { printf("from thread\n");
return NULL; }
int main(void) { pthread_t t;
if (fork() == 0) { printf("from child\n"); pthread_create(&t, NULL, &dummy_thread, NULL); printf("after create\n"); } return 0; }
The output should be (last two lines can be swapped): from child from thread after create
I used the x86 toolchain from the current openwrt trunk to compile it. openwrt/build_dir/toolchain-i386_gcc-4.1.2_uClibc-0.9.29/gcc-4.1.2-final/gcc/gcc-cross fork_thread.c -static -lpthread -o fork_thread
The result was a stopping main thread at pthread_create. I did the same test with 0.9.28.2 and 0.9.30.1 Advanced configuration options ---> Toolchain Options ---> uClibc Version
0.9.28 worked without any problems and 0.9.30.1 without nptl showed the same problem - the nptl version doesn't compile at the moment. So changing the uclibc is a possible solution. Otherwise ask the openwrt developers to take a look at the problem. Please add this example (or a similar one) and the expected results + a list of uclibc versions which worked.
Best regards, Sven