5

我有一个非常复杂的 OpenGL 应用程序在带有 ATI 图形芯片的嵌入式设备上运行,运行 RT linux。应用程序的部分通过单元测试进行测试。它们都通过了,并且没有报告内存泄漏或无效访问。但是,该应用程序有一些怪癖,有些事情表现不佳。

今天我尝试使用 valgrind 运行这个应用程序,在初始化期间我看到一些无效的内存读/写,所有这些都与 ATI 驱动程序有关:

==14347== Invalid read of size 8
==14347==    at 0x67C3868: ??? (in /usr/lib/catalyst/libGL.so.1.2)
==14347==  Address 0x8f6b398 is 208 bytes inside a block of size 212 alloc'd
==14347==    at 0x400AE44: malloc (vg_replace_malloc.c:270)
==14347==    by 0x6762701: ??? (in /usr/lib/catalyst/libGL.so.1.2)
==14347==    by 0x8F6B05F: ???
==14347== 
==14347== Syscall param ioctl(generic) points to uninitialised byte(s)
==14347==    at 0x8A57B9: ioctl (in /lib/libc-2.14.1.so)
==14347==    by 0x6A0E345: ukiCreateContext (in /usr/lib/catalyst/libatiuki.so.1.0)
==14347==    by 0xA9D4570: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xbeceacb4 is on thread 1's stack
==14347== 
==14347== Conditional jump or move depends on uninitialised value(s)
==14347==    at 0xAA46C42: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==    by 0xAA46285: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==    by 0xAA46484: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==    by 0xAA36F32: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347== 
==14347== Invalid write of size 4
==14347==    at 0xAAAA7B4: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb77c2000 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid read of size 4
==14347==    at 0xAAAA95D: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb77d2000 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAA8F3: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb77c2000 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAA8F7: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb77c2010 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAA8FC: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb77c2020 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAA901: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb77c2030 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAA91A: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb77c2040 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAA91F: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb77c2050 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAA924: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb77c2060 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAA929: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb77c2070 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAC2D1: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb7163000 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAC584: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb7163010 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAC588: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb7163020 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 4
==14347==    at 0xAAAC0DD: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb7163550 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 4
==14347==    at 0xAAAC0E3: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb7163554 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 4
==14347==    at 0xAAAC0E9: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb7163558 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 4
==14347==    at 0xAAAC0EF: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb716355c is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 4
==14347==    at 0xAAAC0C5: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70e9300 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 4
==14347==    at 0xAAAC0CB: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70e9304 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 4
==14347==    at 0xAAAC0D1: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70e9308 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 4
==14347==    at 0xAAAC0D7: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70e930c is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid read of size 8
==14347==    at 0xAAAC558: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb870b78 is 3,160 bytes inside a block of size 3,164 alloc'd
==14347==    at 0x400AE44: malloc (vg_replace_malloc.c:270)
==14347==    by 0xA835931: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347== 
==14347== Invalid read of size 8
==14347==    at 0xAAAC418: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb897c68 is 3,160 bytes inside a block of size 3,164 alloc'd
==14347==    at 0x400AE44: malloc (vg_replace_malloc.c:270)
==14347==    by 0xA9A33CE: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAACAE9: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1600 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAACAF3: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1610 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAACAFD: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1620 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAACB07: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1630 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAACB11: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1640 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAC88F: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1800 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAC893: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1810 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAC8A2: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1820 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAC8A7: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1830 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAC8B6: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1840 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAC8BB: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1850 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAC8D0: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1860 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAC8D5: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1870 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 4
==14347==    at 0xAAAC0AD: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1c00 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 4
==14347==    at 0xAAAC0B3: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1c04 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 4
==14347==    at 0xAAAC0B9: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1c08 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 4
==14347==    at 0xAAAC0BF: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1c0c is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid read of size 8
==14347==    at 0xAAAC558: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==    by 0x4F: ???
==14347==  Address 0x8aa8cb8 is 0 bytes after a block of size 80 alloc'd
==14347==    at 0x400AE44: malloc (vg_replace_malloc.c:270)
==14347==    by 0xA9A33CE: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==    by 0x3F: ???
==14347== 
==14347== Invalid write of size 4
==14347==    at 0xAAAC09B: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1400 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 4
==14347==    at 0xAAAC0A1: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1404 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 4
==14347==    at 0xAAAC0A7: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1408 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAACADF: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1000 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid read of size 8
==14347==    at 0xAAAC418: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==    by 0x63010100: ???
==14347==  Address 0x89c6d58 is 0 bytes after a block of size 224 alloc'd
==14347==    at 0x400AE44: malloc (vg_replace_malloc.c:270)
==14347==    by 0xA9A33CE: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347== 
==14347== Invalid read of size 8
==14347==    at 0xAAAC508: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==    by 0x63010100: ???
==14347==  Address 0xbe44b08 is 0 bytes after a block of size 384 alloc'd
==14347==    at 0x400AE44: malloc (vg_replace_malloc.c:270)
==14347==    by 0xA9A33CE: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAACAD5: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1100 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid read of size 8
==14347==    at 0xAAAC698: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xbefdb08 is 3,240 bytes inside a block of size 3,244 alloc'd
==14347==    at 0x400AE44: malloc (vg_replace_malloc.c:270)
==14347==    by 0xA9A33CE: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347== 
==14347== Syscall param ioctl(generic) points to uninitialised byte(s)
==14347==    at 0x8A57B9: ioctl (in /lib/libc-2.14.1.so)
==14347==    by 0xA9DCE45: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==    by 0x8A1AA8F: ???
==14347==  Address 0xbecf8984 is on thread 1's stack
==14347== 
==14347== Syscall param ioctl(generic) points to uninitialised byte(s)
==14347==    at 0x8A57B9: ioctl (in /lib/libc-2.14.1.so)
==14347==    by 0xA9DD354: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xbecf89f0 is on thread 1's stack
==14347== 
==14347== Invalid read of size 8
==14347==    at 0xAAAC558: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==    by 0x63010100: ???
==14347==  Address 0xc7c1288 is 0 bytes after a block of size 3,568 alloc'd
==14347==    at 0x400AE44: malloc (vg_replace_malloc.c:270)
==14347==    by 0xA9A33CE: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==    by 0x63010100: ???
==14347== 
==14347== Invalid write of size 4
==14347==    at 0x9BDC84A: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb70c1a00 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Conditional jump or move depends on uninitialised value(s)
==14347==    at 0x938F092: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347== 
==14347== Conditional jump or move depends on uninitialised value(s)
==14347==    at 0x93B9F10: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAC764: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb6ec2010 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAC768: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb6ec2020 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Conditional jump or move depends on uninitialised value(s)
==14347==    at 0x9F83794: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAC4E4: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb6ec2210 is not stack'd, malloc'd or (recently) free'd
==14347== 
==14347== Invalid write of size 8
==14347==    at 0xAAAC4E8: ??? (in /usr/lib/dri/fglrx_dri.so)
==14347==  Address 0xb6ec2220 is not stack'd, malloc'd or (recently) free'd
==14347== 

我很清楚这些读/写是未定义的行为,并且 ATI 在 linux 上享有不良驱动程序的声誉。

问题是,我应该担心这些错误吗?我知道 valgrind 有时会报告错误的问题。

4

1 回答 1

1

Valgrind 可能会产生误报,尤其是在读取时。这通常发生在将结构复制为块内存时,例如使用 memcopy,因为填充字节。如果读取在分配的块内,这通常是可以的。从释放的内存中读取不是。

但是,无效写入通常是一个问题。

在这种情况下,因为这是一个驱动程序,我怀疑这些与直接内存访问/内存映射 I/O 有关,因此“未堆栈、malloc 或(最近)释放”等等好的。

于 2020-12-24T12:04:48.643 回答