我剛剛收到從Valgrind的輸出,我有點不明白: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,並且所有輸出都如manual中所述。我已經使用了這個valgrind命令:
valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=20 --track-origins=yes
程序本身大喊一個分段錯誤。雖然valgrind這次沒有告訴我任何內存泄漏的位置,但是從調試中我已經確定了發生分段錯誤的地方。不幸的是,它位於英特爾ODE解算器庫(dodesol)的ODE求解器函數中,我無法訪問它。我仔細檢查過我多次傳遞給這個函數的所有參數,他們似乎沒問題(至少對應於我之前手動和示例的那些參數)。
用'-g3'或'-g2'編譯確保符號存在。使用「-O1」或「-O0」編譯以確保符號正確。另請參閱Valgrind快速入門指南中的[準備程序](http://valgrind.org/docs/manual/quick-start.html#quick-start.prepare)。 – jww 2018-01-12 17:48:16