1

在使用 valgrind 时,会显示以下内容:

==2639== Invalid write of size 4
==2639==    at 0x80499EC: sequencer_run (sequencer.c:253)
==2639==    by 0x804E176: thread_start (thread.c:105)
==2639==    by 0x8049072: main (genome.c:237)
==2639==  Address 0xbc1bc3ec is on thread 1's stack
==2639== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==2639==  Access not within mapped region at address 0xBC1BC3EC
==2639==    at 0x80499EC: sequencer_run (sequencer.c:253)

相关代码:

sequencer.c:253  long threadId = thread_getId();

...

long thread_getId()
{
    return (long)(pthread_getspecific(global_threadId));// global_threadId is of type pthread_key_t
}

global_threadId由以下人员创建:

pthread_key_create(&global_threadId, NULL);

并使用赋值

pthread_setspecific(global_threadId, (long)threadId);//(threadId = 0 here)

是返回类型的问题pthread_getspecific(void *)。我尝试修改代码,但无法解决问题。请帮忙。

4

0 回答 0