简体   繁体   English

这个调试断言失败是什么意思?

[英]What does this debug assertion failed mean?

Expression: header->_block_use == block_use ||表达式:header->_block_use == block_use || header->_block_use == _CRT_BLOCK && block_use == _NORMAL_BLOCK header->_block_use == _CRT_BLOCK && block_use == _NORMAL_BLOCK

What does this mean?这是什么意思? It has something to do with a header?它与 header 有关吗?

I found in my code where after I step over it returns the debug assertion failure, just this one line of code works in other projects.我在我的代码中发现,在我跳过它后返回调试断言失败,只有这一行代码在其他项目中有效。

Is there a linker setting or c/c++ setting that I have to remove?是否有我必须删除的 linker 设置或 c/c++ 设置?

The assertion that you are hitting is part of the Microsoft Visual C/C++ runtime libraries, specifically related to the debug heap .您遇到的断言是 Microsoft Visual C/C++ 运行时库的一部分,特别与debug heap相关。 Calling malloc / free and using the new / delete operators leads to calls to the CRT heap functions, which perform internal consistency checks using these assertions.调用malloc / free并使用new / delete运算符会导致调用 CRT 堆函数,这些函数使用这些断言执行内部一致性检查。

It's very likely that the assertion is hit as a result of a memory safety bug, for example trying to delete a garbage pointer, double-free, etc. If you are unable to find it, the ASAN tool can help by keeping closer track of memory operations and raising errors when your code does invalid things.断言很可能是由于 memory 安全错误而命中的,例如尝试删除垃圾指针、双重释放等。如果找不到它,ASAN 工具可以通过更密切地跟踪memory 操作并在您的代码执行无效操作时引发错误。 Without these close checks, mistakes in your code can corrupt a data structure, and the crash could occur much, much later in unrelated code.如果没有这些仔细检查,代码中的错误可能会破坏数据结构,并且在不相关的代码中可能会在很久很久以后发生崩溃。

For Visual Studio, it involves a few steps : the "C++ AddressSanitizer" feature must be installed using the Visual Studio installer, and the address sanitizer must be enabled in the project properties under C/C++ -> General.对于 Visual Studio,它涉及几个步骤:必须使用 Visual Studio 安装程序安装“C++ AddressSanitizer”功能,并且必须在 C/C++ -> General 下的项目属性中启用地址清理器。

Languages such as C and C++ offer an assert(...expression...) facility that is typically used during debugging... and omitted from the final delivered product.诸如 C 和 C++ 之类的语言提供了一个assert(...expression...)工具,通常在调试过程中使用......并且在最终交付的产品中省略。 The ..expression... being "something that should always be False." ..expression...是“应该始终为 False 的东西”。

If the expression turns out not to be False, then it throws a runtime exception containing the exact text of expression .如果expression结果不是False,那么它会引发一个运行时异常,其中包含expression的确切文本。 Which is exactly what a developer would like to see, because: "the whole idea is that this should never, ever, ever happen!"这正是开发人员希望看到的,因为: “整个想法是,这永远不应该发生!”

Ordinarily, published versions of applications are compiled in such a way that all of the assert() statements are ignored: they are "no-ops."通常,已发布的应用程序版本的编译方式是忽略所有assert()语句:它们是“无操作”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM