简体   繁体   English

AddressSanitizer:地址错误时堆栈溢出?

[英]AddressSanitizer: stack-overflow at address error?

So, I have made a function to reverse a linked list using recursion.所以,我做了一个函数来使用递归来反转链表。 My reverse function is working perfectly, but when I try to run asan on my executable, it is giving me a stack-overflow error at a particular address in the reverse function.我的反向函数运行良好,但是当我尝试在我的可执行文件上运行 asan 时,它在反向函数中的特定地址给我一个堆栈溢出错误。 I have tried everything to fix it.我已经尝试了一切来修复它。 I tried to make all the variables in the stack NULL after their work is done.在完成工作后,我尝试将堆栈中的所有变量设为 NULL。 I have de-allocated all the memory from the heap.我已经从堆中取消分配了所有内存。 I ran valgrind on the file and it tells me all the memory has been freed and there is no leak.我在文件上运行 valgrind ,它告诉我所有内存都已释放并且没有泄漏。 What do I do?我该怎么办?

AddressSanitizer: stack-overflow AddressSanitizer:堆栈溢出

PS I am using clang++ compiler in C++. PS我在C++中使用clang++编译器。

ASAN increases your memory requirements since it inserts sentinel values on the stack. ASAN 会增加您的内存需求,因为它会在堆栈中插入标记值。 So it's possible you aren't hitting the stack limit normally but you are now with ASAN enabled, since each recursive call is now using more stack space than it was before.因此,您可能没有正常达到堆栈限制,但您现在启用了 ASAN,因为每个递归调用现在使用的堆栈空间比以前更多。

The best thing to do in C++ is to not recurse so deeply, but you can also increase your process's stack limits, eg in bash:在 C++ 中最好的做法是不要进行如此深入的递归,但您也可以增加进程的堆栈限制,例如在 bash 中:

ulimit -s unlimited

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

相关问题 AddressSanitizer:地址上的堆缓冲区溢出 - AddressSanitizer: heap-buffer-overflow on address LeetCode C++ 将 char[] 转换为字符串,抛出 AddressSanitizer: stack-buffer-overflow 错误 - LeetCode C++ Convert char[] to string, throws AddressSanitizer: stack-buffer-overflow error 为什么我在 leetcode 上收到 AddressSanitizer: heap-buffer-overflow on address 0x602000000058 错误? - Why am I getting AddressSanitizer: heap-buffer-overflow on address 0x602000000058 error on leetcode? 错误:AddressSanitizer:地址 X 上的堆缓冲区溢出 pc Y bp Z sp W - ERROR: AddressSanitizer: heap-buffer-overflow on address X at pc Y bp Z sp W 对称传输不会防止 C++20 协程的堆栈溢出 - Symmetric transfer does not prevent stack-overflow for C++20 coroutines LeetCode为什么会给出错误:AddressSanitizer:堆缓冲区溢出? - Why does LeetCode give the ERROR : AddressSanitizer: heap-buffer-overflow? 最长回文 substring。错误:AddressSanitizer,堆溢出 - longest palindromic substring. Error: AddressSanitizer, heap overflow 为什么 AddressSanitizer 报告堆栈使用后作用域错误? - Why is AddressSanitizer reporting a stack-use-after-scope error? 如何在 gcc 中抑制来自 AddressSanitizer 的堆栈缓冲区溢出 - How can I suppress a stack-buffer-overflow from AddressSanitizer in gcc 堆栈溢出或指针错误? - Stack overflow or pointer error?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM