当我使用 gdb 运行程序时收到此错误消息。错误显示在这一行:
long a = thread_fake(); //in file1.c
我遇到了在单独文件中定义的其他函数的问题,因此我将其简化为仅返回 0 的简单函数。该函数已定义为:
long thread_fake(){ //defined in file2.c
return 0;
}
正如@EmployedRussian 指出的那样,程序似乎用完了堆栈。valgrind 显示以下错误:
==14711== 144 bytes in 1 blocks are possibly lost in loss record 17 of 32
==14711== at 0x4025315: calloc (vg_replace_malloc.c:467)
==14711== by 0x4010CD7: allocate_dtv (dl-tls.c:300)
==14711== by 0x401146B: _dl_allocate_tls (dl-tls.c:464)
==14711== by 0x40475C6: pthread_create@@GLIBC_2.1 (allocatestack.c:570)
==14711== by 0x8050583: tm_main_startup
==14711== by 0x8048F6B: main (genome.c:201)
==14711== 144 bytes in 1 blocks are possibly lost in loss record 18 of 32
==14711== at 0x4025315: calloc (vg_replace_malloc.c:467)
==14711== by 0x4010CD7: allocate_dtv (dl-tls.c:300)
==14711== by 0x401146B: _dl_allocate_tls (dl-tls.c:464)
==14711== by 0x40475C6: pthread_create@@GLIBC_2.1 (allocatestack.c:570)
==14711== by 0x804DFE3: thread_startup (thread.c:151)
==14711== by 0x8048F73: main (genome.c:203)
所有创建的线程都加入了相应的 pthread_join 调用。我也尝试了 sgcheck 工具,但它在平台'x86-linux'上不起作用。请帮忙。
bt 命令的完整输出:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x406e8b70 (LWP 19416)]
sequencer_run (argPtr=0x89fce00) at sequencer.c:251
251 a = thread_fake();
(gdb) bt
#0 sequencer_run (argPtr=0x89fce00) at sequencer.c:251
#1 0x0804e306 in threadWait (argPtr=0x89dc1f4) at ../lib/thread.c:105
#2 0x4003be99 in start_thread (arg=0x406e8b70) at pthread_create.c:304
#3 0x40253cbe in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130