I have a a single error when I run my program through valgrind. The problem is that it wont tell me where the uninitialised bytes were allocated:
==22141== Syscall param write(buf) points to uninitialised byte(s)
==22141== at 0x5B68900: __write_nocancel (syscall-template.S:82)
==22141== by 0x5AFB882: _IO_file_write@@GLIBC_2.2.5 (fileops.c:1289)
==22141== by 0x5AFB749: new_do_write (fileops.c:543)
==22141== by 0x5AFCEB4: _IO_do_write@@GLIBC_2.2.5 (fileops.c:516)
==22141== by 0x5AFDD3E: _IO_switch_to_get_mode (genops.c:189)
==22141== by 0x5AFBA96: _IO_file_seekoff@@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)
Would I be correct in assuming this means some sort of invalid pointer to the stack? This happens in rewind() and I do not understand why rewind would be like this. I tried attaching the valgrind process to gdb and I tried to print the result of the ftell() on the file pointer. This caused valgrind to exit with this:
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: _IO_file_write@@GLIBC_2.2.5 (fileops.c:1289)
==22938== by 0x5AFB749: new_do_write (fileops.c:543)
==22938== by 0x5AFCEB4: _IO_do_write@@GLIBC_2.2.5 (fileops.c:516)
==22938== by 0x5AFDD3E: _IO_switch_to_get_mode (genops.c:189)
==22938== by 0x5AFBA96: _IO_file_seekoff@@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: ???
How would I go about determining the cause of this error?
Edit: I fixed the other issue I was having but this persists.
This is from the code here: https://github.com/MatthewLM/cbitcoin/blob/master/test/testCBAddressManager.c
The file IO code is here: https://github.com/MatthewLM/cbitcoin/tree/master/dependencies/storage
Thank you.