Valgrind reporting a segment overflow

Tim Kuipers picture Tim Kuipers · Feb 1, 2016 · Viewed 19k times · Source

When running my program with valgrind / callgrind I get the following message a lot:

==21734== brk segment overflow in thread #1: can't grow to 0x4a39000 (with different addresses)

Note that it is not preceded by a stack overflow message.

I can't find any documentation on this message and I have no idea what is overflowing exactly.

Can anybody help me figure out what the problem is? Is this a problem of valgrind, or of my program?

Answer

Piwi picture Piwi · Oct 27, 2016

Line 1327 from the valgrind source code points to the user manual, "see section Limitations in user manual":

Limits section item 1:

On Linux, Valgrind determines at startup the size of the 'brk segment' using the RLIMIT_DATA rlim_cur, with a minimum of 1 MB and a maximum of 8 MB. Valgrind outputs a message each time a program tries to extend the brk segment beyond the size determined at startup. Most programs will work properly with this limit, typically by switching to the use of mmap to get more memory. If your program really needs a big brk segment, you must change the 8 MB hardcoded limit and recompile Valgrind.