无论如何,是否有 valgrind 消息“条件跳转或移动取决于未初始化的值"?可能是所谓的“误报" [英] Is there anyway a valgrind message "Conditional jump or move depends on uninitialized value" can be a so called 'false positive'

查看:16
本文介绍了无论如何,是否有 valgrind 消息“条件跳转或移动取决于未初始化的值"?可能是所谓的“误报"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里找到的大多数问题都提供了一段代码,并由指出实际错误的人回答.我的问题是关于一般未初始化值的条件跳转.我可以理解,如果确定此分配仅完成一次并且在程序的生命周期内可能需要,则不必在程序结束时清除一块内存.据我所知,当程序终止时,GType 系统会留下大量未释放的内存.这些未释放的块可以被视为误报".但是有条件跳转或移动未初始化的值"会是误报吗?我唯一能想到的是有人通过读取随机地址来实现(坏)随机化函数(其中随机地址本身是棘手的部分;).另一个例子可能是硬件映射到内存的一部分,然后读取,但这主要是由驱动程序完成的,而不是由普通用户应用程序完成的.是否还有其他示例(最好是 C)会导致这种误报?

Most questions I find here provide a piece of code and get answered by someone pointing to the actual error. My question is about conditional jumps on uninitialized values in general. I can understand that a piece of memory should not necessarily be cleaned at the end of a program if one is sure this allocation is done only once and will probably be needed during the lifetime of a program. As far as I remember the GType system leaves a lot of unfreed memory when the program terminates. These unfreed blocks can be seen as 'false positives'. But can a 'conditional jump or move on uninitialized value' be a false positive? The only thing I can come up with is someone implementing a (bad) randomize function by just reading a random address (where the random address itself is the tricky part ;). Another example could be hardware mapped to a part of the memory which is then read, but this is mostly done by drivers and not by normal user applications. Is there any other example (preferably C) which could cause such a false positive?

推荐答案

valgrind 报告的是,它看到基于读取位置的跳转,它知道它是由程序分配的,但它没有't 看到一个初始化.如果对象是由 valgrind 不知道的某种魔法初始化的,则可能会发生这种情况.架构不断发展,也许您有一个 valgrind 不太了解的指令或寄存器类型.

What valgrind is reporting is that it sees a jump based on a read from a location for which it knows that it was allocated by the program but for which it hasn't seen an initialization. This might happen if the object is initialized by some magic that valgrind doesn't know about. Architectures evolve constantly and maybe you have an instruction or register type that valgrind doesn't know enough about.

这种非初始化的另一个困难来源是union.两个来源:

Another difficult source of such non-initializations are unions. Two sources:

  • 默认情况下,对于这些,只有第一个成员被初始化,所以当另一个字段超出第一个成员时,该部分可能是未初始化.
  • 如果 union 的成员是 struct 他们可能有填充字节在不同的地方,因此成员的一部分可能是如果您分配给其他成员,则未初始化.
  • Per default, for these only the first member is initialized and so when another field goes beyond that first member that part might be uninitialized.
  • If the members of the union are struct they may have padding bytes at different places, and so part of a member may be uninitialized if you assigned to a different member.

在某些情况下,甚至阅读这些东西(例如通过 unsigned char[] )可能是合法的,因此如果您认为诸如错误(误报)之类的东西是一个问题视角.

In some cases it might be legitimate to even read these things (through a unsigned char[] for example) so if you consider such things as a bug (false positive) or not is a matter of perspective.

这篇关于无论如何,是否有 valgrind 消息“条件跳转或移动取决于未初始化的值"?可能是所谓的“误报"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆