Reputation: 3877
When trying to debug my C++ binary, I am running into the following issue.
valgrind: m_mallocfree.c:307 (get_bszB_as_is): Assertion 'bszB_lo == bszB_hi' failed.
valgrind: Heap block lo/hi size mismatch: lo = 1, hi = 4294967295.
This is probably caused by your program erroneously writing past the
end of a heap block and corrupting heap metadata. If you fix any
invalid writes reported by Memcheck, this assertion failure will
probably go away. Please try that before reporting this as a bug.
host stacktrace:
==1747== at 0x58013284: ??? (in /usr/lib64/valgrind/massif-amd64-linux)
==1747== by 0x58013397: ??? (in /usr/lib64/valgrind/massif-amd64-linux)
==1747== by 0x58013531: ??? (in /usr/lib64/valgrind/massif-amd64-linux)
==1747== by 0x5801BD6D: ??? (in /usr/lib64/valgrind/massif-amd64-linux)
==1747== by 0x5800CDC1: ??? (in /usr/lib64/valgrind/massif-amd64-linux)
==1747== by 0x580614A7: ??? (in /usr/lib64/valgrind/massif-amd64-linux)
==1747== by 0x580737A7: ??? (in /usr/lib64/valgrind/massif-amd64-linux)
==1747== by 0x580738DC: ??? (in /usr/lib64/valgrind/massif-amd64-linux)
==1747== by 0x580C9561: ??? (in /usr/lib64/valgrind/massif-amd64-linux)
==1747== by 0x580C96AA: ??? (in /usr/lib64/valgrind/massif-amd64-linux)
==1747== by 0x580720CD: ??? (in /usr/lib64/valgrind/massif-amd64-linux)
==1747== by 0xDEADBEEFDEADBEEE: ???
==1747== by 0xDEADBEEFDEADBEEE: ???
==1747== by 0xDEADBEEFDEADBEEE: ???
sched status:
running_tid=47
Thread 47: status = VgTs_Runnable (lwpid 1861)
==1747== at 0x4C2922D: free (vg_replace_malloc.c:540)
==1747== by 0x9A7CB7B: __libc_freeres (in /usr/lib64/libc-2.17.so)
==1747== by 0x4A24739: _vgnU_freeres (vg_preloaded.c:77)
client stack range: ??????? client SP: 0x289569C8
valgrind stack range: [0x1009516000 0x1009615FFF] top usage: 5064 of 1048576
But the interesting fact is, it works wonderfully well when same binary is running outside the container (on a VM). If my source binary has a memory link (as per Valgrind FAQs) I am puzzled as to why I am not encountering the issue when not running in a container.
Any help appreciated.
Upvotes: 0
Views: 1835
Reputation: 411
Most likely it is this issue: https://github.com/sfackler/rust-postgres/issues/74#issuecomment-301464576
I encountered this in a Docker container based off centos:7
and could also reproduce it using --tool=memcheck
. Adding --run-libc-freeres=no
to the valgrind call fixed the issue for me.
Upvotes: 1