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
>Organization:
>Environment:
System: NetBSD jaguar-gamma 6.0_POST_RC1 NetBSD 6.0_POST_RC1 (XEN3PAE_DOMU) #7:
Mon Sep 10 10:53:12 CEST 2012
ignatios%random84.cs.uni-bonn.de@localhost:/var/itch/sources/6.0/oi386/sys/arch/i386/compile/XEN3PAE_DOMU
i386
Architecture: i386
Machine: i386
>Description:
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().
>How-To-Repeat:
$ cat test.c
#include <pthread.h>
#include <stdlib.h>
int
main(int argc, char **argv)
{
(void)malloc(10);
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/libpthread.so.1
#1 0x00000050 in ?? ()
#2 0xbb7e9000 in ?? ()
#3 0xbb75da9f in malloc () from /usr/lib/libc.so.12
#4 0x080487ca in main (argc=1, argv=0xbf7feb54) at test.c:8
>Fix:
Link with -pg when compiled with -pg or don't use pthreads.
>Unformatted:
Home |
Main Index |
Thread Index |
Old Index