Valgrind を使用して C++ アプリケーションのメモリ リークをチェックし始めたところです。しかし、プログラムが Sqlite3 データベースを開こうとするたびに、SIGSEGV で終了します。これは、Valgrind なしで実行した場合には発生しません。
これを示す最も簡単なプログラムは次のとおりです。
int main (int argc, char** argv) {
sqlite3 *db = 0;
sqlite3_open("/tmp/mydb.sqlite", &db);
return 0;
}
Valgrind は次のように報告しています。
==29227== Jump to the invalid address stated on the next line
==29227== at 0x0: ???
==29227== by 0x48C606: mallocWithAlarm (in /opt/local/lib/libsqlite3.0.8.6.dylib)
==29227== by 0x477F71: sqlite3Malloc (in /opt/local/lib/libsqlite3.0.8.6.dylib)
==29227== by 0x4BD7F5: pthreadMutexAlloc (in /opt/local/lib/libsqlite3.0.8.6.dylib)
==29227== by 0x47740F: sqlite3_initialize (in /opt/local/lib/libsqlite3.0.8.6.dylib)
==29227== by 0x48929D: openDatabase (in /opt/local/lib/libsqlite3.0.8.6.dylib)
==29227== by 0x10014B507: main (in /usr/local/bin/outbound)
==29227== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==29227==
==29227==
==29227== Process terminating with default action of signal 11 (SIGSEGV)
==29227== Bad permissions for mapped region at address 0x0
==29227== at 0x0: ???
==29227== by 0x48C606: mallocWithAlarm (in /opt/local/lib/libsqlite3.0.8.6.dylib)
==29227== by 0x477F71: sqlite3Malloc (in /opt/local/lib/libsqlite3.0.8.6.dylib)
==29227== by 0x4BD7F5: pthreadMutexAlloc (in /opt/local/lib/libsqlite3.0.8.6.dylib)
==29227== by 0x47740F: sqlite3_initialize (in /opt/local/lib/libsqlite3.0.8.6.dylib)
==29227== by 0x48929D: openDatabase (in /opt/local/lib/libsqlite3.0.8.6.dylib)
==29227== by 0x10014B507: main (in /usr/local/bin/outbound)
Valgrind でこの動作が発生する原因は何ですか?