1

I have compiled a simple pthread_create program and executed the same in NetBSD5.1 on ARMv7 target(cortex a9 CPU).

the program sigfaults. The same pthread program is running in another PC without any issue.

Below is the sample program

void *PrintHello(void *threadid){
    long tid, i;
    tid = (long)threadid;
    for (i=0; i<PRINT_REPEAT; i++) {
        printf("Hello World! It's me, thread #%ld!\n", tid); 
    };
    pthread_exit(NULL);
}

int main (int argc, char *argv[])
{
    pthread_t threads[NUM_THREADS];
    int rc;
    int t;
    printf("PrintHello is %p\r\n",(void *)PrintHello);
    for(t=0; t<NUM_THREADS; t++){
        rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
    if (rc){
        printf("ERROR; return code from pthread_create() is %d\n", rc);
        }
       }
    pthread_exit(NULL);
}

Any pointers on this would be very helpful. I am seeing that the data_abort_handler exception is being raised on executing the program.

  • Following is the call stack I have received. Loaded symbols for /usr/libexec/ld.elf_so (gdb) bt #0 0x4003ad64 in pthread_setcancelstate () from /usr/lib/libpthread.so.0 #1 0x400af724 in inet_network () from /usr/lib/libc.so.12 #2 0x400af724 in inet_network () from /usr/lib/libc.so.12 Previous frame identical to this frame (corrupt stack?) – Zaid Ibrahime Feb 09 '16 at 07:38
  • I have also tried the compiling the same C program with -static linker option and got the below backtrace 0x0002335c in __flockfile_internal () (gdb) bt #0 0x0002335c in __flockfile_internal () #1 0x00022b88 in fflush () #2 0x00022b88 in fflush () – Zaid Ibrahime Feb 09 '16 at 07:39
  • Any reason you're using NetBSD 5.1? NetBSD 5.1 is no longer supported, NetBSD 7.0 and 6.1 are the current supported releases. – Eric Schnoebelen Feb 09 '16 at 14:54
  • What operating system and version is running on the "PC"? – Eric Schnoebelen Feb 09 '16 at 14:55
  • NetBSD5.1 is the OS running. I am using this because this machine is already up and running. I am trying to add pthread library. – Zaid Ibrahime Feb 10 '16 at 05:13
  • Your test code is incomplete, but I see it is basically one of the examples from the POSIX Threads Programming tutorial: https://computing.llnl.gov/tutorials/pthreads/samples/hello.c – Greg A. Woods Feb 10 '16 at 19:59
  • It is incredibly easy to put 7.0 on a MicroSD card and boot it up and try it. The original example program I linked to works fine on my RPi with 7.99.8. – Greg A. Woods Feb 10 '16 at 20:01

0 Answers0