當我通過valgrind運行我的程序時,出現一個錯誤。問題是,它不會告訴我哪裏有未初始化的字節被分配:Valgrind無法找到未初始化數據的堆棧分配
==22141== Syscall param write(buf) points to uninitialised byte(s)
==22141== at 0x5B68900: __write_nocancel (syscall-template.S:82)
==22141== by 0x5AFB882: [email protected]@GLIBC_2.2.5 (fileops.c:1289)
==22141== by 0x5AFB749: new_do_write (fileops.c:543)
==22141== by 0x5AFCEB4: [email protected]@GLIBC_2.2.5 (fileops.c:516)
==22141== by 0x5AFDD3E: _IO_switch_to_get_mode (genops.c:189)
==22141== by 0x5AFBA96: [email protected]@GLIBC_2.2.5 (fileops.c:999)
==22141== by 0x5AF4F25: rewind (rewind.c:37)
==22141== by 0x567D149: CBFileAppend (CBFileEC.c:69)
==22141== by 0x5473AFA: CBDatabaseCreateDeletionIndex (CBDatabase.c:270)
==22141== by 0x5473195: CBInitDatabase (CBDatabase.c:112)
==22141== by 0x54721A1: CBNewAddressStorage (CBAddressStorage.c:37)
==22141== by 0x401F67: main (testCBAddressManager.c:226)
==22141== Address 0x402a009 is not stack'd, malloc'd or (recently) free'd
==22141== Uninitialised value was created by a stack allocation
==22141== at 0x546F750: ??? (in /media/sf_BitEagle_Projects/cbitcoin/bin/libcbitcoin-storage.2.0.so)
我將是假設這意味着一些無效的指針的堆棧是否正確?這發生在rewind()中,我不明白爲什麼倒帶會是這樣的。我嘗試將valgrind進程附加到gdb,並試圖在文件指針上打印ftell()的結果。這導致valgrind與此退出:
valgrind: m_syswrap/syswrap-main.c:1296 (vgPlain_client_syscall): Assertion 'sci->status.what == SsIdle' failed.
==22938== at 0x3804CA36: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
==22938== by 0x3804CBDC: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
==22938== by 0x38091F55: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
==22938== by 0x3808E5DF: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
==22938== by 0x3808F739: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
==22938== by 0x3809F7D5: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
sched status:
running_tid=1
Thread 1: status = VgTs_Runnable
==22938== at 0x5B68900: __write_nocancel (syscall-template.S:82)
==22938== by 0x5AFB882: [email protected]@GLIBC_2.2.5 (fileops.c:1289)
==22938== by 0x5AFB749: new_do_write (fileops.c:543)
==22938== by 0x5AFCEB4: [email protected]@GLIBC_2.2.5 (fileops.c:516)
==22938== by 0x5AFDD3E: _IO_switch_to_get_mode (genops.c:189)
==22938== by 0x5AFBA96: [email protected]@GLIBC_2.2.5 (fileops.c:999)
==22938== by 0x5AF1AA5: ftell (ioftell.c:41)
==22938== by 0x40133F: ??? (in /media/sf_BitEagle_Projects/cbitcoin/bin/testCBAddressManager)
==22938== by 0xF75E467: ???
==22938== by 0x7FEFFF3BF: ???
==22938== by 0xF75E467: ???
==22938== by 0x546DE87: ??? (in /media/sf_BitEagle_Projects/cbitcoin/bin/libcbitcoin-storage.2.0.so)
==22938== by 0x7FEFFF3DF: ???
我將如何去確定此錯誤的原因?
編輯:我解決了我遇到的其他問題,但這仍然存在。
這是從這裏代碼:https://github.com/MatthewLM/cbitcoin/blob/master/test/testCBAddressManager.c
文件IO代碼是在這裏:https://github.com/MatthewLM/cbitcoin/tree/master/dependencies/storage
謝謝。
您使用哪個過程來安裝valgrind? – Sebivor
我很確定這是包含在Linux Mint中,我不需要自己安裝它。 –
請給我們展示一個最小的可編譯測試用例。 – Sebivor