102

When I was running my program against valgrind, I encountered the following warning.

Warning: set address range perms: large range [0x4d59d040, 0x6159d040) (undefined)
Warning: set address range perms: large range [0x194f7030, 0x2d4f7050) (noaccess)
Warning: set address range perms: large range [0x3959d030, 0x6159d050) (noaccess)

After some googling I found at here that it is a Diagnostic message, mostly for benefit of the Valgrind developers, to do with memory permissions, which doesn't tell me much.

My program does allocate a large amount of memory on heap. (Can reach 2-3 GB of ram after a whole bunch of realloc's)

However, the warning appeared despite none of the allocations failed.

So, I'm wondering what this message really means? I don't have some sort of memory permission? (But allocation succeeded)

jsj
  • 9,019
  • 17
  • 58
  • 103
Jimmy Lu
  • 4,810
  • 7
  • 25
  • 30
  • The valgrind manual has improved a lot over the past years. If anyone is interested in the meanings of `undefined` and `noaccess` in valgrind now they may refer to [this section of the online manual](https://valgrind.org/docs/manual/mc-manual.html#mc-manual.machine). – Weijun Zhou May 24 '22 at 10:12

1 Answers1

104

It just means that the permissions changed on a particularly large block of memory.

That can happen because of something like a call to mprotect or when a very large memory allocation or deallocation occurs - an mmap or munmap call for example.

The first one you list is setting about 320Mb of memory to undefined which is most likely a new allocation, which will be marked as undefined initially. The others are both setting similar sized blocks to noaccess which probably relates to a deallocation of memory.

TomH
  • 8,900
  • 2
  • 32
  • 30
  • 4
    I see. Is this something that one should ever be worried about? (I'm guessing not as it's `mostly for benefit of the Valgrind developers`?) – Jimmy Lu Nov 26 '12 at 14:31
  • 21
    I've expanded and clarified my answer a bit but basically, no, it isn't generally anything you need to worry about. – TomH Nov 26 '12 at 15:47
  • What if it lists five errors ending with: (defined) - (noaccess) - (defined) - (noaccess) - (defined)? – Adam Hunyadi May 29 '17 at 08:55
  • In addition, Valgrind's throws a warning for allocation / free of size ``0xFFFFFD1`` or greater. The real limit should be ``0x10000000`` yet Valgrind add some extra bytes before and after the size. Example : ``malloc(12)``, with Valgrind enabled will give : ``malloc(20 + 12 + 20)``. Valgrind's acceptable size's value is ``0xFFFFFD0`` for the alloc and the free. – Ximaz Nov 05 '22 at 22:51