我做了一个不幸的决定,卸载了我为 petsc/gcc/macports/brew/ 等工作的东西,因为 Valgrind 不适合我。我让 Valgrind 为我工作,重新安装了 Petsc 和 slepc 等,但是在我成功创建可执行文件 ./hello 之后,我遇到了这个问题:
==25882== Process terminating with default action of signal 11 (SIGSEGV) ==25882== Access not within mapped region at address 0x18 ==25882== at 0x103E31808: _pthread_wqthread_setup (in /usr/lib/system/libsystem_pthread.dylib) ==25882== by 0x103E31497: _pthread_wqthread (in /usr/lib/system/libsystem_pthread.dylib) ==25882== by 0x103E313FC: start_wqthread (in /usr/lib/system/libsystem_pthread.dylib) ==25882== If you believe this happened as a result of a stack ==25882== overflow in your program's main thread (unlikely but ==25882== possible), you can try to increase the size of the ==25882== main thread stack using the --main-stacksize= flag. ==25882== The main thread stack size used in this run was 8388608. ==25882== LEAK SUMMARY: ==25882== definitely lost: 512 bytes in 1 blocks ==25882== indirectly lost: 0 bytes in 0 blocks ==25882== possibly lost: 128 bytes in 1 blocks ==25882== still reachable: 212,531 bytes in 1,554 blocks ==25882== suppressed: 747,772 bytes in 740 blocks ==25882== Reachable blocks (those to which a pointer was found) are not shown. ==25882== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==25882== ==25882== For lists of detected and suppressed errors, rerun with: -s ==25882== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 2238 from 184) Segmentation fault: 11
我的程序是一个简单的程序:
int main(int argc, char *argv[]){
int i;
PetscInitialize(&argc, &argv, NULL, NULL);
printf("HELLO\n");
PetscFinalize();
return 0; }
当我通过 Valgrind 执行我的程序时,我遇到了分段错误,但是当我在没有 Valgrind 的情况下运行它时,我没有遇到任何问题或分段错误。瓦尔格林问题?添加时出现段错误 11
PetscInitialize(&argc, &argv, NULL, NULL);
PetscFinalize();
我该如何解决这个问题?