简体   繁体   English

Xcode解决消毒剂实际警告的问题是什么?

[英]What kind of problems does Xcode address sanitizer actually warn about?

Xcode 7 has a new feature called address sanitizer, which is introduced in the release notes with this short description: Xcode 7有一个名为address sanitizer的新功能,它在发行说明中引入了这个简短的描述:

  • Address sanitizer points out code that may crash at runtime even when you cannot reproduce yourself 地址清理程序指出可能在运行时崩溃的代码,即使您无法自我复制

Apart from the ironic wording, I believe what is meant here is that the address sanitizer is supposed to detect (irreproducible) problems that may result in access violations or other fatal application errors. 除了具有讽刺意味的措辞外,我认为这里的意思是地址消毒剂应该检测(不可再现的)可能导致访问违规或其他致命应用程序错误的问题。

Apple Developer adds more information making it clear that this is a diagnostic tool (not a compiler feature) intended to catch memory corruption issues at debug time. Apple Developer添加了更多信息,清楚地表明这是一种用于在调试时捕获内存损坏问题的诊断工具(不是编译器功能)。

I did a few tests on my own but couldn't put together a piece of code that would trigger the address sanitizer when run. 我自己做了一些测试,但无法将一段代码放在一起,以便在运行时触发地址消毒剂。 Could somebody provide me with an example? 有人可以给我一个例子吗? I was looking for a sample in C, but objective C would be fine as well. 我正在寻找C中的样本,但客观C也会很好。

Here is more information about the address sanitizer and here's a simple test: 以下是有关地址消毒剂的更多信息 ,这是一个简单的测试:

char test()
{
    char buffer[4] = { 9, 8, 7, 6 };
    unsigned index = 4;
    return buffer[index];
}

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

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