执行出错 ================================================================= ==20==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000000040 at pc 0x557dd915fbf4 bp 0x7ffe457c4460 sp 0x7ffe457c4450 WRITE of size 8 at 0x602000000040 thread T0 #1 0x7f1640af6082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) 0x602000000040 is located 0 bytes to the right of 16-byte region [0x602000000030,0x602000000040) allocated by thread T0 here: #0 0x7f164173ea06 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:153 #4 0x7f1640af6082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) Shadow bytes around the buggy address: 0x0c047fff7fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c047fff7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c047fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c047fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c047fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =>0x0c047fff8000: fa fa fd fd fa fa 00 00[fa]fa 00 00 fa fa 00 00 0x0c047fff8010: fa fa 00 00 fa fa 00 00 fa fa fa fa fa fa fa fa 0x0c047fff8020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff8030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb Shadow gap: cc ==20==ABORTING
时间: 2023-08-24 08:05:32 浏览: 183
正确理解Python中if __name__ == '__main__'
这个错误是由于堆缓冲区溢出导致的。在你的代码中,有一次写入操作超出了分配的内存空间。
要解决这个问题,你可以检查代码中的内存分配和写入操作,确保它们的范围是正确的。请特别注意循环和数组索引,确保不会超出分配的内存空间。
此外,你还可以使用工具来帮助调试和检测内存错误,比如 AddressSanitizer(ASan)。ASan 是一个用于检测内存错误的工具,可以在编译时启用它,以获得更详细的错误信息和堆栈跟踪。
希望这能帮助你解决问题!如果你还有其他问题,请随时提问。
阅读全文