gpt4 book ai didi

python - 在 valgrind 下运行 python 显示很多内存错误是否正常?

转载 作者:IT老高 更新时间:2023-10-28 21:11:14 31 4
gpt4 key购买 nike

我尝试在我的 Python C 扩展中调试内存崩溃,并尝试在 valgrind 下运行脚本。我发现 valgrind 输出中有太多“噪音”,即使我运行了简单的命令:

valgrind python -c ""

Valgrind 的输出充满了这样的重复信息:

==12317== Invalid read of size 4
==12317== at 0x409CF59: PyObject_Free (in /usr/lib/libpython2.5.so.1.0)
==12317== by 0x405C7C7: PyGrammar_RemoveAccelerators (in /usr/lib/libpython2.5.so.1.0)
==12317== by 0x410A1EC: Py_Finalize (in /usr/lib/libpython2.5.so.1.0)
==12317== by 0x4114FD1: Py_Main (in /usr/lib/libpython2.5.so.1.0)
==12317== by 0x8048591: main (in /usr/bin/python2.5)
==12317== Address 0x43CD010 is 7,016 bytes inside a block of size 8,208 free'd
==12317== at 0x4022F6C: free (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==12317== by 0x4107ACC: PyArena_Free (in /usr/lib/libpython2.5.so.1.0)
==12317== by 0x41095D7: PyRun_StringFlags (in /usr/lib/libpython2.5.so.1.0)
==12317== by 0x40DF262: (within /usr/lib/libpython2.5.so.1.0)
==12317== by 0x4099569: PyCFunction_Call (in /usr/lib/libpython2.5.so.1.0)
==12317== by 0x40E76CC: PyEval_EvalFrameEx (in /usr/lib/libpython2.5.so.1.0)
==12317== by 0x40E70F3: PyEval_EvalFrameEx (in /usr/lib/libpython2.5.so.1.0)
==12317== by 0x40E896A: PyEval_EvalCodeEx (in /usr/lib/libpython2.5.so.1.0)
==12317== by 0x40E8AC2: PyEval_EvalCode (in /usr/lib/libpython2.5.so.1.0)
==12317== by 0x40FD99C: PyImport_ExecCodeModuleEx (in /usr/lib/libpython2.5.so.1.0)
==12317== by 0x40FFC93: (within /usr/lib/libpython2.5.so.1.0)
==12317== by 0x41002B0: (within /usr/lib/libpython2.5.so.1.0)

Slackware 12.2 上的 Python 2.5.2。

这是正常行为吗?如果是这样,那么 valgrind 可能不适合在 Python 中调试内存错误?

最佳答案

您可以尝试使用 suppression file自带的python源码

阅读Python Valgrind README也是个好主意!

关于python - 在 valgrind 下运行 python 显示很多内存错误是否正常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1519276/

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