Software bug that seems to change when debugging
调试时似乎会更改的软件错误
For the Linux distribution codenamed Heisenbug, see Fedora Linux
有关Linux分销代号为Heisenbug,请参见Fedora Linux
Not to be confused with Heisenberg
不要与海森伯格混淆
In computer programming jargon, a heisenbug is a software bug that seems to disappear or alter its behavior when one attempts to study it.[1] The term is a pun on the name of Werner Heisenberg, the physicist who first asserted the observer effect of quantum mechanics, which states that the act of observing a system inevitably alters its state. In electronics, the traditional term is probe effect, where attaching a test probe to a device changes its behavior.
在计算机编程术语中,Heisenbug是一个软件错误,在尝试研究时似乎会消失或改变其行为。[1]该术语是以物理学家Werner Heisenberg的名义的双关语,他首先主张了量子力学的观察者效应,该量子指出,观察系统的行为不可避免地会改变其状态。在电子学中,传统术语是探针效应,其中将测试探针附加到设备上改变了其行为。
Similar terms, such as bohrbug, mandelbug,[2][3][4] hindenbug, and schrödinbug[5][6] (see the section on related terms) have been occasionally proposed for other kinds of unusual software bugs, sometimes in jest.[7][8]
类似的术语,例如Bohrbug,Mandelbug,[2] [3] [4] Hindenbug和Schrödinbug[5] [6](请参阅相关术语的部分)有时会出于其他类型的不寻常的软件错误而提出。
Examples [ edit ]
示例[编辑]
Heisenbugs occur because common attempts to debug a program, such as inserting output statements or running it with a debugger, usually have the side-effect of altering the behavior of the program in subtle ways, such as changing the memory addresses of variables and the timing of its execution.
之所以发生HeisenBugs,是因为进行调试程序的常见尝试,例如插入输出语句或使用调试器运行,通常具有以微妙的方式改变程序行为的副作用,例如更改变量的内存地址和执行时间的时间。
One common example of a heisenbug is a bug that appears when the program is compiled with an optimizing compiler, but not when the same program is compiled without optimization (as is often done for the purpose of examining it with a debugger). While debugging, values that an optimized program would normally keep in registers are often pushed to main memory. This may affect, for instance, the result of floating-point comparisons, since the value in memory may have smaller range and accuracy than the value in the register[citation needed]. Similarly, heisenbugs may be caused by side-effects in test expressions used in runtime assertions in languages such as C and C++, where the test expression is not evaluated when assertions are turned off in production code using the NDEBUG macro.
Heisenbug的一个常见示例是一个错误,当程序通过优化编译器编译时会出现,但是当在没有优化的情况下编译相同的程序(通常是为了使用调试器检查)时,它不会出现。在调试时,优化程序通常会保存在寄存器中的值通常会推向主要内存。例如,这可能会影响浮点比较的结果,因为内存中的值的范围和准确性可能比寄存器中的值较小[所需的引用]。类似地,海森虫可能是由在C和C ++等语言中使用的测试表达式中使用的副作用引起的,在使用NDEBUG宏中关闭生产代码中的断言时,未评估测试表达式。
Other common causes of heisenbugs are using the value of a non-initialized variable (which may change its address or initial value during debugging), or following an invalid pointer (which may point to a different place when debugging). Debuggers also commonly allow the use of breakpoints or provide other user interfaces that cause additional source code (such as property accessors) to be executed stealthily, which can, in turn, change the state of the program.[9]
海森虫的其他常见原因是使用非原始变量的值(在调试期间可能会更改其地址或初始值),或遵循无效的指针(在调试时可能指向其他位置)。调试者通常还允许使用断点或提供其他用户接口,这些用户接口会偷偷地执行其他源代码(例如属性访问者),从而可以更改程序的状态。[9]
End-Users can experience a heisenbug when the act of making a screenshot of the heisenbug for observation fixes the heisenbug and the screenshot shows a perfectly working state. This effect can happen when complex stacks of software work together, for example a web browser using a hardware graphic card acceleration which causes rendering errors on the physical screen that do not show on a screenshot.
当制作Heisenbug的屏幕截图以观察时,最终用户可以体验到Heisenbug,可以修复Heisenbug,并且屏幕截图显示出完美的工作状态。当复杂的软件一起工作时,可能会发生这种效果,例如使用硬件图形卡加速器的Web浏览器,该加速器会在物理屏幕上导致渲染错误,而该错误错误在屏幕截图上未显示。
Time can also be a factor in heisenbugs, particularly with multi-threaded applications. Executing a program under control of a debugger can change the execution timing of the program as compared to normal execution. Time-sensitive bugs, such as race conditions, may not occur when the program is slowed down by single-stepping source lines in the debugger. This is particularly true when the behavior involves interaction with an entity not under the control of a debugger, such as when debugging network packet processing between two machines and only one is under debugger control.
时间也可能是Heisenbugs的一个因素,尤其是在多线程应用程序中。与正常执行相比,执行在调试器控制下的程序可以更改程序的执行时间。当调试器中的单步源线减慢程序时,可能不会发生时间敏感的错误,例如种族条件。当行为涉及与不受调试器控制的实体互动时,例如在两台机器之间调试网络数据包处理时,只有一台在调试器控制下进行调试时,尤其如此。
Heisenbugs can be viewed as instances of the observer effect in information technology. Frustrated programmers may humorously blame a heisenbug on the phase of the moon,[10] or (if it has occurred only once) may explain it away as a soft error due to alpha particles or cosmic rays affecting the hardware, a well-documented phenomenon known as single event effects.
Heisenbugs可以看作是信息技术观察者效应的实例。令人沮丧的程序员可能会幽默地归咎于月球阶段,[10]或(如果仅发生一次)可能会将其解释为由于影响硬件的alpha颗粒或宇宙射线而导致的软误差,这是一种有据可查的现象,称为单一事件效应。
Related terms [ edit ]
相关术语[编辑]
A bohrbug, by way of contrast, is a"good, solid bug". Like the deterministic Bohr atom model, they do not change their behavior and are relatively easily detected.[11][12]
相反,Bohrbug是一个“良好,可靠的错误”。像确定性的Bohr原子模型一样,它们不会改变其行为并相对容易检测到。[11] [12]
A mandelbug (named after Benoît Mandelbrot's fractal) is a bug whose causes are so complex it defies repair, or makes its behavior appear chaotic or even non-deterministic.[2] The term also refers to a bug that exhibits fractal behavior (that is, self-similarity) by revealing more bugs (the deeper a developer goes into the code to fix it the more bugs they find).[citation needed]
曼德尔布格(以BenoîtMandelbrot的分形命名)是一个错误,其原因是如此复杂,无法修复或使其行为显得混乱甚至不确定性。[2]该术语还指的是一个通过揭示更多错误(即开发人员越深入探讨其发现的错误)来表现出分形行为(即自相似性)的错误。
A schrödinbug or schroedinbug (named after Erwin Schrödinger and his thought experiment) is a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.[5]
Schrödinbug或Schroedinbug(以Erwinschrödinger和他的思想实验命名)是一个错误,在程序员注意到代码不应首先工作后,在运行软件中表现出来。[5] [5]
A hindenbug[13] (named after the Hindenburg disaster) is a bug with catastrophic behavior.
Hindenbug [13](以兴登堡灾难的名字命名)是灾难性行为的错误。
A higgs-bugson[14][15] (named after the Higgs boson particle) is a bug that is predicted to exist based upon other observed conditions (most commonly, vaguely related log entries and anecdotal user reports) but is difficult, if not impossible, to artificially reproduce in a development or test environment. The term may also refer to a bug that is obvious in the code (mathematically proven), but which cannot be seen in execution (yet difficult or impossible to actually find in existence).
Higgs-Bugson [14] [15](以Higgs Boson粒子的名字命名)是一个基于其他观察到的条件(最常见的,隐约相关的日志条目和轶事用户报告)预测存在的错误,但如果不是不可能,则在开发或测试环境中可以人工繁殖。该术语也可以指代码中明显的错误(数学证明),但在执行中无法看到(但很难或无法实际发现)。
Etymology [ edit ]
词源[编辑]
The earliest known appearance is from 1983, in an ACM publication.[16]
最早的外观是从1983年的ACM出版物中。[16]
The term was used in 1985 by Jim Gray, in a paper about software failures,[17] and is sometimes mistakenly attributed to him because of this publication. It was used in 1986 by Jonathan Clark and Zhahai Stewart on the mailing list (later Usenet news group) comp.risks.[18]
吉姆·格雷(Jim Gray)于1985年在有关软件失败的论文中使用了该术语[17],有时由于该出版物而被错误地归因于他。它于1986年由乔纳森·克拉克(Jonathan Clark)和Zhahai Stewart在邮件列表中(后来的Usenet新闻集团)使用。[18]
Bruce Lindsay, a researcher at IBM, affirmed in a 2004 ACM Queue interview that he was present when the Heisenbug was originally defined,[19] but did not state when this occurred.
IBM的研究人员布鲁斯·林赛(Bruce Lindsay)在2004年的ACM队列采访中确认,他最初定义了Heisenbug时他在场,[19],但没有说明发生这种情况的情况。
Resolution [ edit ]
分辨率[编辑]
Heisenbugs are difficult to identify and fix; often attempting to resolve them leads to further unexpected behavior. Because the problem manifests as the result of a separate, underpinning bug, the behavior can be hard to predict and analyze during debugging. Overall the number of heisenbugs identified should decrease as a piece of software matures.[20]
海森虫很难识别和修复。通常试图解决它们会导致进一步的意外行为。由于该问题表现为单独的基础错误的结果,因此在调试期间很难预测和分析该行为。总体而言,被识别的高亨次数量应随着软件的成熟而减少。[20]
See also [ edit ]
另请参见[编辑]
Cargo cult programming
货物邪教编程
Jinx Debugger—a tool that automatically explores executions likely to expose Heisenbugs
JINX调试器 - 一种工具,该工具自动探索可能暴露Heisenbugs的执行
Memory debugger
内存调试器