valgrind: Heap block lo/hi size mismatch when trying to debug a C++ program running inside Docker container

Karthik Jayaraman <[email protected]>
Newsgroups gmane.comp.debugging.valgrind
Message-ID <[email protected]>
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.

-Karthik
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.