C语言 这个 Valgrind 警告是什么意思?- 警告设置地址范围权限

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13558067/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 04:34:55  来源:igfitidea点击:

What Does This Valgrind Warning Mean? - warning set address range perms

cmemoryvalgrind

提问by Jimmy Lu

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

当我针对 valgrind 运行我的程序时,我遇到了以下警告。

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 herethat it is a Diagnostic message, mostly for benefit of the Valgrind developers, to do with memory permissions, which doesn't tell me much.

经过一番谷歌搜索后,我在这里发现它是一个Diagnostic message, mostly for benefit of the Valgrind developers, to do with memory permissions,这并没有告诉我太多。

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)

我的程序确实在堆上分配了大量内存。(在一堆realloc's之后可以达到 2-3 GB 的 ram )

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)

所以,我想知道这条消息的真正含义是什么?我没有某种内存权限?(但分配成功)

采纳答案by TomH

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

这只是意味着权限在一个特别大的内存块上发生了变化。

That can happen because of something like a call to mprotector when a very large memory allocation or deallocation occurs - an mmapor munmapcall for example.

这可能是由于调用mprotect或发生非常大的内存分配或解除分配之类的事情而发生的 -例如调用mmapmunmap调用。

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

您列出的第一个是设置大约 320Mb 的内存,undefined这很可能是一个新分配,最初将被标记为未定义。其他人都设置了类似大小的块,noaccess这可能与内存释放有关。