未初始化的值是由库代码上的堆栈分配错误创建的

Uninitialised value was created by a stack allocation error on library code

您好,我目前正在修复我的 valgrind 错误,它们是:

==11925== ERROR SUMMARY: 9 errors from 1 contexts (suppressed: 0 from 0)
==11925== 
==11925== 9 errors in context 1 of 1:
==11925== Syscall param ioctl(generic) points to uninitialised byte(s)
==11925==    at 0xF8B7F47: ioctl (syscall-template.S:84)
==11925==    by 0x1F770DAD: drmIoctl (in /opt/amdgpu/lib/x86_64-linux-gnu/libdrm.so.2.4.0)
==11925==    by 0x1F7756E8: drmCommandWriteRead (in /opt/amdgpu/lib/x86_64-linux-gnu/libdrm.so.2.4.0)
==11925==    by 0x3332C6AC: amdgpu_create_bo_from_user_mem (in /opt/amdgpu/lib/x86_64-linux-gnu/libdrm_amdgpu.so.1.0.0)
==11925==    by 0x32A479F2: ??? (in /usr/lib/x86_64-linux-gnu/gallium-pipe/pipe_radeonsi.so)
==11925==    by 0x32A6E6B3: ??? (in /usr/lib/x86_64-linux-gnu/gallium-pipe/pipe_radeonsi.so)
==11925==    by 0x2D8E8BD6: ??? (in /usr/lib/x86_64-linux-gnu/libMesaOpenCL.so.1.0.0)
==11925==    by 0x2D8E05D4: ??? (in /usr/lib/x86_64-linux-gnu/libMesaOpenCL.so.1.0.0)
==11925==    by 0x2D8DE2D4: ??? (in /usr/lib/x86_64-linux-gnu/libMesaOpenCL.so.1.0.0)
==11925==    by 0x2D8DD2E7: ??? (in /usr/lib/x86_64-linux-gnu/libMesaOpenCL.so.1.0.0)
==11925==    by 0x2D8DD940: ??? (in /usr/lib/x86_64-linux-gnu/libMesaOpenCL.so.1.0.0)
==11925==    by 0x2D8D8875: ??? (in /usr/lib/x86_64-linux-gnu/libMesaOpenCL.so.1.0.0)
==11925==  Address 0xffeffed64 is on thread 1's stack
==11925==  in frame #3, created by amdgpu_create_bo_from_user_mem (???:)
==11925==  Uninitialised value was created by a stack allocation
==11925==    at 0x329770B0: ??? (in /usr/lib/x86_64-linux-gnu/gallium-pipe/pipe_radeonsi.so)

在我的程序中,我与错误代码中提到的文件无关。我已经阅读了很多关于这个问题的帖子,但就我而言,提到的代码行 甚至在我的代码中也不存在 (我想它在我使用的某个库中)。

感谢您的帮助!

将未初始化的缓冲区传递给 ioctl 是很常见的。

valgrind 中甚至有一个选项可以忽略它们:

--sim-hints=lax-ioctls

查看文档 http://valgrind.org/docs/manual/manual-core.html

lax-ioctls: Be very lax about ioctl handling; the only assumption is that the size is correct. Doesn't require the full buffer to be initialised when writing. Without this, using some device drivers with a large number of strange ioctl commands becomes very tiresome.

简而言之,您的错误(很可能)是误报。