Hello. I faced a problem I can't solve by myself so I will be grateful for any help. This code causes segfault:
#include <poll.h> #include <pthread.h>
static void * thread_func (void *arg) { int count = 0; struct pollfd pfds[1] = { 0 }; poll(pfds, count, 1000); }
int main () { pthread_t thread; if (pthread_create(&thread, NULL, thread_func, NULL)) return 1; if (pthread_cancel(thread)) return 2; if (pthread_join(thread, NULL)) return 3; return 0; }
This is how backtrace looks:
Thread 2 received signal SIG32.
Thread 2: #0 0xb76b24f6 in __poll_nocancel (fds=0xb76a0414, nfds=0, timeout=1000) at libc/sysdeps/linux/common/poll.c:27 #1 0xb76b2585 in __GI_poll (fds=0xb76a0414, nfds=0, timeout=1000) at libc/sysdeps/linux/common/poll.c:208 #2 0x080484c3 in thread_func () #3 0xb77954b0 in start_thread (arg=0xb76ebba0) at libpthread/nptl/pthread_create.c:285 #4 0xb76fcae7 in clone () at libc/sysdeps/linux/i386/clone.S:103
Thread 1: #0 0xb77996f1 in pthread_join (threadid=3077487520, thread_return=0x0) at libpthread/nptl/pthread_join.c:88 #1 0x08048522 in main ()
Architecture is i386. Interesting thing is that segmentation fault only happens when uClibc-ng built with debug enabled (DODEBUG=y).
Thank you.