gpt4 book ai didi

c - 为什么 valgrind 的堆栈跟踪分为两部分?

转载 作者:行者123 更新时间:2023-11-30 15:17:39 28 4
gpt4 key购买 nike

the docs ,解释 Valgrind 的 Memcheck 错误报告,4.2.1 节中有一个这样的例子。非法读取/非法写入错误:

Invalid read of size 4
at 0x40F6BBCC: (within /usr/lib/libpng.so.2.1.0.9)
by 0x40F6B804: (within /usr/lib/libpng.so.2.1.0.9)
by 0x40B07FF4: read_png_image(QImageIO *) (kernel/qpngio.cpp:326)
by 0x40AC751B: QImageIO::read() (kernel/qimage.cpp:3621)
Address 0xBFFFF0E0 is not stack'd, malloc'd or free'd

这是我的例子:

==20285== Invalid read of size 8
==20285== at 0x401E8C: arraylist_get (arraylist.c:68)
==20285== by 0x401254: test_arraylist_remove (test_arraylist.c:68)
==20285== by 0x401366: main (tests.c:31)
==20285== Address 0x59d65f0 is 0 bytes inside a block of size 2 alloc'd
==20285== at 0x4C2CE8E: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20285== by 0x402302: pool_realloc (pool.c:57)
==20285== by 0x401D97: arraylist_remove (arraylist.c:53)
==20285== by 0x401243: test_arraylist_remove (test_arraylist.c:67)
==20285== by 0x401366: main (tests.c:31)

注意 - 就我而言,Address 0x59d65f0 is 0 bytes inside a block of size 2 alloc'd 之后有一个延续 - 此错误中还有另一个堆栈跟踪。这是什么意思?

ps
完整的 Valgrind 输出:
https://gist.github.com/AndrewPashkin/b1b1b484153642b1ae14

最佳答案

这是两个独立的堆栈跟踪。

首先,对无效访问的描述,以及该点代码的堆栈跟踪:

==20285== Invalid read of size 8
==20285== at 0x401E8C: arraylist_get (arraylist.c:68)
==20285== by 0x401254: test_arraylist_remove (test_arraylist.c:68)
==20285== by 0x401366: main (tests.c:31)

其次,对正在访问的内存的描述,以及分配它的代码的堆栈跟踪:

==20285==  Address 0x59d65f0 is 0 bytes inside a block of size 2 alloc'd
==20285== at 0x4C2CE8E: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20285== by 0x402302: pool_realloc (pool.c:57)
==20285== by 0x401D97: arraylist_remove (arraylist.c:53)
==20285== by 0x401243: test_arraylist_remove (test_arraylist.c:67)
==20285== by 0x401366: main (tests.c:31)

关于c - 为什么 valgrind 的堆栈跟踪分为两部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32212703/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com