Valgrind reporting a segment overflow

Solution 1:

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.

Solution 2:

Valgrind only allocates 8MB for the brk segment, which runs out. One reports that libc is then switching to a mmap-based memory allocation in the valgrind bugreport discussing this.

Solution 3:

While this is not really an answer, it still satisfies OP's "couldn't find any docs" requirement:

1) http://repo.or.cz/valgrind.git/blob/HEAD:/coregrind/m_syswrap/syswrap-generic.c

contains the message discussed at line 1322

2) http://sourceforge.net/p/valgrind/mailman/message/34068401/

is the commit that introduced the feature, and the corresponding commit message reads

Author: florian
Date: Wed Apr 29 13:59:16 2015
New Revision: 15155

Log: Issue an error message if then brk segment overflows.

from where we can further relay this question on to those who can give a qualified answer to "what exactly does "a brk segment overflows" mean in this context"!

Solution 4:

Adding to Piwi's answer, sometimes your program will require Callgrind to use a bigger brk segment (up to GBs, depending on your implementation).

To modify the hardcoded limit, go to function VG_(ii_create_image) in coregrind/m_initimg/initimg-linux.c (around line 1000), change the following lines according to your needs

SizeT m1 = 1024 * 1024;
SizeT m8 = 8 * m1;

and rebuild valgrind.

m8 is the max brk segment size that callgrind will try to allocate