NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

toolchain/47105: compiling with -pg, linking with -lpthread & without -pg -> core dump

>Number:         47105
>Category:       toolchain
>Synopsis:       compiling with -pg, linking with -lpthread & without -pg -> 
>core dump
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 22 09:40:00 +0000 2012
>Originator:     Matthias Kretschmer
>Release:        NetBSD 6.0_POST_RC1
System: NetBSD jaguar-gamma 6.0_POST_RC1 NetBSD 6.0_POST_RC1 (XEN3PAE_DOMU) #7: 
Mon Sep 10 10:53:12 CEST 2012
Architecture: i386
Machine: i386
Compiling with -pg and then linking the result with -lpthread but
without -pg makes the resulting program sometimes crash in
pthread_mutex_lock() called by malloc().
$ cat test.c
#include <pthread.h>
#include <stdlib.h>

main(int argc, char **argv)

    return EXIT_SUCCESS;

$ gcc -c -g -pg test.c
$ gcc -o test test.o -lpthread
$ while true; do ./test; done
[1]   Segmentation fault (core dumped) ./test
[1]   Segmentation fault (core dumped) ./test
[1]   Segmentation fault (core dumped) ./test

$ gdb ./test -c test.core
(gdb) bt
#0  0xbb7deab2 in pthread_mutex_lock () from /usr/lib/
#1  0x00000050 in ?? ()
#2  0xbb7e9000 in ?? ()
#3  0xbb75da9f in malloc () from /usr/lib/
#4  0x080487ca in main (argc=1, argv=0xbf7feb54) at test.c:8
Link with -pg when compiled with -pg or don't use pthreads.


Home | Main Index | Thread Index | Old Index