[英]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.