VirtualBox

Ticket #10094 (new enhancement)

Opened 2 years ago

Last modified 15 months ago

Valgrind's memcheck hard to use with VirtualBox OpenGL drivers

Reported by: wolf42 Owned by:
Priority: minor Component: 3D support
Version: VirtualBox 4.1.8 Keywords:
Cc: Guest type: Linux
Host type: other

Description (last modified by frank) (diff)

Host: Windows 7 64 bit with nvidia GPU.
Guest: Ubuntu with VirtualBox OpenGL driver.

Test case

/* gcc test.c `sdl-config --libs --cflags` */
#include <SDL.h>

int main( int argc, char** argv )
{
	SDL_Init( SDL_INIT_VIDEO );
	SDL_SetVideoMode( 16, 16, 32, SDL_OPENGL );
	return 0;
}

Steps to reproduce

  1. Compile the test case.
  2. Run the compiled program through valgrind's memcheck tool (run valgrind ./a.out).

Results

Valgrind reports a significant amount of errors originating in VirtualBox OpenGL driver. Example:

==3028== Conditional jump or move depends on uninitialised value(s)
==3028==    at 0x51193B9: ??? (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLpackspu.so)
==3028==    by 0x50D588B: crNetDispatchMessage (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLcrutil.so)
==3028==    by 0x50DF2EB: ??? (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLcrutil.so)
==3028==    by 0x50DEBCE: ??? (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLcrutil.so)
==3028==    by 0x50DEF64: ??? (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLcrutil.so)
==3028==    by 0x50D517B: crNetSend (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLcrutil.so)
==3028==    by 0x511962D: packspuFlush (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLpackspu.so)
==3028==    by 0x51178A8: packspu_CreateContext (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLpackspu.so)
==3028==    by 0x57B42D2: feedbackspu_CreateContext (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLfeedbackspu.so)
==3028==    by 0x501984C: stubMakeCurrent (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGL.so)
==3028==    by 0x502EC53: vboxstub_glXMakeCurrent (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGL.so)
==3028==    by 0x5031E49: vbox_glXMakeCurrent (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGL.so)
==3028== 
==3028== Use of uninitialised value of size 4
==3028==    at 0x5119338: ??? (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLpackspu.so)
==3028==    by 0x51193FC: ??? (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLpackspu.so)
==3028==    by 0x50D588B: crNetDispatchMessage (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLcrutil.so)
==3028==    by 0x50DF2EB: ??? (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLcrutil.so)
==3028==    by 0x50DEBCE: ??? (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLcrutil.so)
==3028==    by 0x50DEF64: ??? (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLcrutil.so)
==3028==    by 0x50D517B: crNetSend (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLcrutil.so)
==3028==    by 0x511962D: packspuFlush (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLpackspu.so)
==3028==    by 0x51178A8: packspu_CreateContext (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLpackspu.so)
==3028==    by 0x57B42D2: feedbackspu_CreateContext (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGLfeedbackspu.so)
==3028==    by 0x501984C: stubMakeCurrent (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGL.so)
==3028==    by 0x502EC53: vboxstub_glXMakeCurrent (in /opt/VBoxGuestAdditions-4.1.8/lib/VBoxOGL.so)

The amount of reported errors increases with each single OpenGL instruction used in code. Such behavior makes looking for real application errors very hard, if not impossible to do.

Note that, despite all the errors reported, VirtualBox OpenGL drivers do NOT misbehave in any way (whether running under valgrind or not).

Expected result

Valgrind reports no errors, or the errors number is very limited and they originate from SDL or X. This happens when the test case is run on a non-virtualized Linux machine with nvidia drivers.

Additional info

Other people also have reported this issue:
 https://forums.virtualbox.org/viewtopic.php?f=6&t=32378
 https://forums.virtualbox.org/viewtopic.php?f=3&t=45319

Change History

comment:1 Changed 2 years ago by frank

I don't think this is an error at all. The guest drivers communicate with the host and valgrind doesn't know about this. From the guests point of view it looks like some values magically appear. This is not a bug, some would need to write proper valgrind rules to disable these warnings.

comment:2 Changed 2 years ago by wolf42

I have tried to write suppression rules for these "errors", but the sheer amount of the "errors" generated makes it very difficult. Besides, suppressing the "errors" would also hide the real errors, eg.:

  • out-of-bounds reads when passed buffer is smaller than the defined size - error would originate in the drivers during copy,
  • uninitialized values in buffer (eg. problems with texture loading, wrong vbo indices, etc) - error originates much later in driver (during usage, copying uninitialized values is fine).

While I understand that the driver implementation is as intended and working fine, I cannot accept dismissing this issue as non-problematic in the given context.

comment:3 Changed 2 years ago by frank

  • Type changed from defect to enhancement

You are right that such errors could be hidden by suppression rules but, again, this is NOT a VirtualBox bug, perhaps more a feature request.

comment:4 Changed 15 months ago by inorton

The right answer here is for oracle to provide a suppression file for valgrind.

Many of the errors or warnings are down to un-initialized memory, quite possibly these have actually been initialized by the VM host.

comment:5 Changed 15 months ago by inorton

Following  http://wiki.wxwidgets.org/Valgrind_Suppression_File_Howto#How_to_make_a_suppression_file I've created a basic suppression file.

 vbox_linux_opengl.supp

I still get some warnings but it is a good start for someone else to pick up.

comment:6 Changed 15 months ago by frank

  • Description modified (diff)

Most warnings you see are not dues to actually un-initialized memory but they are false positives. Memory in userland is sometimes 'magically' initialized by the kernel code and/or by the VMM.

And I already said that this is more a feature request than a bug exactly for this reason. Thanks for the initial version of a suppression file.

Note: See TracTickets for help on using tickets.

www.oracle.com
ContactPrivacy policyTerms of Use