检测到错误后,Can Address Sanitizer会立即中止吗?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了检测到错误后,Can Address Sanitizer会立即中止吗?相关的知识,希望对你有一定的参考价值。

我正在使用系统调用检查程序与-fsanitize = address结合使用,当ASAN发现错误时,它会在打印报告时调用一些系统调用(ioctl(ISATTY)等)。系统调用检查程序会中断ASAN的ioctl,并且无法正确收集错误报告。

我想要的是ASAN在没有打印报告的情况下简单地中止,或者失败,一种确定(使用libasan4 API调用可能)ASAN发现错误的方法,因此我可以阻止系统调用检查器拦截系统调用。

不幸的是,来自libasan4的__asan_error_report__sanitizer_set_death_callback__asan_set_error_report_callback都在ASAN收集报告后开始:

0 __asan_error_report()
1 syscall_checker()
2 ioctl(ISATTY)
3 asan::PrintReport()
4 app_code_that_crashes()

并且系统调用检查器不能正确处理ASAN的ioctl()调用,所以它正常退出(),而我希望保持ASAN的abort()行为。

答案

您应该能够在覆盖__asan_on_error(在asan_interface.h中声明,默认为空)打印报告之前拦截:

// User may provide function that would be called right when ASan detects
// an error. This can be used to notice cases when ASan detects an error, but
// the program crashes before ASan report is printed.
void __asan_on_error();

请注意,由于奇怪的Asan回调接口,您最好在主二进制文件中实现此回调(共享库中的定义可能无法拦截libasan.a中的默认定义)。

以上是关于检测到错误后,Can Address Sanitizer会立即中止吗?的主要内容,如果未能解决你的问题,请参考以下文章

ERROR: Can‘t get master address from ZooKeeper; znode data == null HBASEZookeeper相关错误解决方案,亲测好用

es启动报错BindException: Can't assign requested address

Navicat for Mysql 远程连接数据库 出现 1042-Can't get hostname for your address 错误! 是啥问题。

关于CAN总线的被动错误标志的问题?

Capl编程xml标签语法 —— CAN报文周期检测/错误帧检测/信号改变检测。。。

mysql报错1024-can't get hostname for your address