使用信号11 [SIGSEGV]的默认操作终止的进程

时间:2012-09-17 09:05:39

标签: gcc segmentation-fault valgrind

我正在Eclipse中构建一个C ++项目。它使用SQLITE3作为数据库,使用libxml从XML文件中读取特定数据。代码编译良好,生成可执行文件。但是,当我运行二进制文件时,它会以此消息Segmentation fault (core dumped)终止。

当我运行Valgrind探查器来检测内存泄漏的位置时,我得到了一个我无法理解的巨大日志文件。

    ==4960== Invalid read of size 4
    ==4960==    at 0x41C6EB7: sqlite3SafetyCheckSickOrOk (sqlite3.c:22048)
    ==4960==    by 0x41EADCA: sqlite3_close (sqlite3.c:112926)
    ==4960==    by 0x804A551: Database::close() (CEMDAPnew.cpp:133)
    ==4960==    by 0x805D2F3: CDataCoordinator::ReadVehicleMakeData(std::string) (DataCoordinator.cpp:2709)
    ==4960==    by 0x80689D4: main (GauravWithoutMPI.cpp:36)
    ==4960==  Address 0x4dc1fd0 is 64 bytes inside a block of size 512 free'd
    ==4960==    at 0x402B06C: free (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
    ==4960==    by 0x41B520F: sqlite3MemFree (sqlite3.c:15252)
    ==4960==    by 0x41A2DF0: sqlite3_free (sqlite3.c:18986)
    ==4960==    by 0x41EB0B4: sqlite3_close (sqlite3.c:113040)
    ==4960==    by 0x804A551: Database::close() (CEMDAPnew.cpp:133)
    ==4960==    by 0x805D2F3: CDataCoordinator::ReadVehicleMakeData(std::string) (DataCoordinator.cpp:2709)
    ==4960==    by 0x80689D4: main (GauravWithoutMPI.cpp:36)
    ==4960== 
    ==4960== Conditional jump or move depends on uninitialised value(s)
    ==4960==    at 0x4532DD8: inflateReset2 (in /lib/i386-linux-gnu/libz.so.1.2.3.4)
    ==4960==    by 0x4532EC7: inflateInit2_ (in /lib/i386-linux-gnu/libz.so.1.2.3.4)
    ==4960==    by 0x512FE6B: ???
    ==4960== 
    ==4960== Conditional jump or move depends on uninitialised value(s)
    ==4960==    at 0x4532DD8: inflateReset2 (in /lib/i386-linux-gnu/libz.so.1.2.3.4)
    ==4960==    by 0x4532EC7: inflateInit2_ (in /lib/i386-linux-gnu/libz.so.1.2.3.4)
    ==4960==    by 0x5056E135: ???
    ==4960== 
    ==4960== Invalid read of size 4
    ==4960==    at 0x80BD81C: CMdcevMM::loadXmlString(_xmlNode*, _xmlDoc*, unsigned char*) (ModelModule.cpp:2849)
    ==4960==    by 0x810D73A: CSimCoordinator::LoadXmlString(char const*) (simCoordinator.cpp:8313)
    ==4960==    by 0x8068A4E: main (GauravWithoutMPI.cpp:45)
    ==4960==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
    ==4960== 
    ==4960== 
    ==4960== Process terminating with default action of signal 11 (SIGSEGV)

我需要理解这个输出。任何人都可以帮助我理解这个错误,这里有什么问题?

感谢。

1 个答案:

答案 0 :(得分:2)

首先,您应该开始修复Invalid read错误。它们是分段错误的最可能原因,它与内存泄漏无关。

Valgrind输出中的第一个Invalid read表示sqlite3SafetyCheckSickOrOk调用引用之前已释放的某些内存。它发生的确切调用堆栈打印在下面。这看起来很奇怪,因为它发生在sqlite3_close中,而不是指释放的内存。可能这是sqlite bug。

第二个Invalid read表示引用CMdcevMM::loadXmlString中的NULL指针。检查你的代码。