This works for me, perhaps you can post some data related to your efforts, or cut it down to smaller chunks and run an experiment. I have little thread experience, but a good amount of core file experience, and further was about to suggest that you set the core file limits from within your program using the setrlimit() function; however I searched for a simple pthread example, put an intentional fault within the thread, set my ulimit -c unlimited in my terminal, compiled, ran it, got a core file and verified that the core file backtraces to the error point in the thread.
Here's the example I grabbed, and many thanks to Tim Murphy for writing a simple, good pthread example:
PThreads in C - A Minimal Working Example.
What I changed is in the *inc_x() function just after the declaration for int *x_ptr and assignment, I re-assigned x_ptr to be NULL; thus when it would be used, it should cause a core dump:
Code:
/* this function is run by the second thread */
void *inc_x(void *x_void_ptr)
{
/* increment x to 100 */
int *x_ptr = (int *)x_void_ptr;
x_ptr = NULL; // my change to cause a core file dump
while(++(*x_ptr) < 100); // this is line 10 - relevant to the future error
Here's how to compile this, because you'll need both GDB and pthreads, and then run it, and debug it. Note that I named my test file thread.c, commands typed by me have been colored green:
Code:
~/testcode$ gcc -ggdb -o thread -l pthread thread.c
~/testcode$ ulimit -c unlimited
~/testcode$ ./thread
x: 0, y: 0
y increment finished
Segmentation fault (core dumped)
~/testcode$ gdb thread core
GNU gdb (GDB) 7.1-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from ~/testcode/thread...done.
[New Thread 12949]
[New Thread 12948]
warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/tls/i686/cmov/libpthread.so.0...(no debugging symbols found)...done.
Loaded symbols for /lib/tls/i686/cmov/libpthread.so.0
Reading symbols from /lib/tls/i686/cmov/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/tls/i686/cmov/libc.so.6
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2
Core was generated by `./thread'.
Program terminated with signal 11, Segmentation fault.
#0 0x0804857a in inc_x (x_void_ptr=0xbfe865bc) at thread.c:10
10 while(++(*x_ptr) < 100);
(gdb) bt
#0 0x0804857a in inc_x (x_void_ptr=0xbfe865bc) at thread.c:10
#1 0xb78aa96e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#2 0xb7818a4e in clone () from /lib/tls/i686/cmov/libc.so.6
(gdb)