我刚刚从 valgrind 收到一个我不太明白的输出:
==20290== Invalid read of size 1
==20290== at 0x8C1D678: ???
==20290== by 0x5D74C47: ???
==20290== Address 0xee818c7d is not stack'd, malloc'd or (recently) free'd
==20290==
==20290==
==20290== Process terminating with default action of signal 11 (SIGSEGV)
==20290== Access not within mapped region at address 0xEE818C7D
==20290== at 0x8C1D678: ???
==20290== by 0x5D74C47: ???
==20290== If you believe this happened as a result of a stack
==20290== overflow in your program's main thread (unlikely but
==20290== possible), you can try to increase the size of the
==20290== main thread stack using the --main-stacksize= flag.
==20290== The main thread stack size used in this run was 8388608.
==20290==
特别是,我对这些问号感到困惑。通常你在这个地方得到的是 valgrind 检测到的错误的位置。我以前使用过 valgrind,所有输出都如手册中所述。我使用了这个 valgrind 命令:
valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=20 --track-origins=yes
程序本身会出现分段错误。虽然这次valgrind没有告诉我内存泄漏的任何位置,但从调试中我已经确定了发生分段错误的位置。不幸的是,它位于英特尔 ODE 求解器库 (dodesol) 的 ODE 求解器函数中,我无法访问它。我已经多次仔细检查了我传递给这个函数的所有参数,它们似乎没问题(至少与我之前的手册和示例中的参数相对应)。