Bug 255987

Summary: Allow suppressions based on origins tracking
Product: [Developer tools] valgrind Reporter: Bartosz Taudul <wolf.pld>
Component: memcheckAssignee: Julian Seward <jseward>
Status: REPORTED ---    
Severity: wishlist CC: retrosharephenom
Priority: NOR    
Version First Reported In: 3.6.0   
Target Milestone: ---   
Platform: Unlisted Binaries   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Bartosz Taudul 2010-11-03 18:59:20 UTC
In some configurations, simple suppressions are not enough to ignore some errors without false positives.

Consider the following code:
#include <stdio.h>
#include <SDL.h>
#include <GL/gl.h>

int main()
{
        int size;

        SDL_Init( SDL_INIT_VIDEO );
        SDL_SetVideoMode( 64, 64, 24, SDL_OPENGL );

        glGetIntegerv( GL_MAX_TEXTURE_SIZE, &size );

        if( size )  /* error here */
        {
                printf( "%i\n", size );
        }

        return 0;
}

When run, it executes correctly:
% ./a.out
8192

On a sane OpenGL implementation valgrind doesn't report any errors:
% LIBGL_ALWAYS_INDIRECT=1 DISPLAY=192.168.1.2:0 valgrind ./a.out
==2238== Memcheck, a memory error detector
==2238== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==2238== Using Valgrind-3.6.0 and LibVEX; rerun with -h for copyright info
==2238== Command: ./a.out
==2238==
8192
==2238==
==2238== HEAP SUMMARY:
(...)

But when the application uses VirtualBox host 3D acceleration, the fun begins:
==2225== Conditional jump or move depends on uninitialised value(s)
==2225==    at 0x804857F: main (dupa.c:14)

The only suppression valgrind can generate is:
{
   <insert_a_suppression_name_here>
   Memcheck:Cond
   fun:main
}

Which is obviously too broad. Only the origin tracking can be used to eliminate the culprit:
==2225==  Uninitialised value was created by a heap allocation
==2225==    at 0x4024733: malloc (vg_replace_malloc.c:236)
==2225==    by 0x4B3EF9C: crAlloc (in /opt/VBoxGuestAdditions-3.2.10/lib/VBoxOGLcrutil.so)
==2225==    by 0x4B4A1EB: crVBoxHGCMConnection (in /opt/VBoxGuestAdditions-3.2.10/lib/VBoxOGLcrutil.so)
==2225==    by 0x4B3F459: ??? (in /opt/VBoxGuestAdditions-3.2.10/lib/VBoxOGLcrutil.so)
==2225==    by 0x4B3F622: crNetConnectToServer (in /opt/VBoxGuestAdditions-3.2.10/lib/VBoxOGLcrutil.so)
==2225==    by 0x4B40106: crNetServerConnect (in /opt/VBoxGuestAdditions-3.2.10/lib/VBoxOGLcrutil.so)
==2225==    by 0x4B8253A: packspuConnectToServer (in /opt/VBoxGuestAdditions-3.2.10/lib/VBoxOGLpackspu.so)
==2225==    by 0x4B80D71: packspuNewThread (in /opt/VBoxGuestAdditions-3.2.10/lib/VBoxOGLpackspu.so)
==2225==    by 0x4B817A1: ??? (in /opt/VBoxGuestAdditions-3.2.10/lib/VBoxOGLpackspu.so)
==2225==    by 0x4AF3D5E: crSPULoad (in /opt/VBoxGuestAdditions-3.2.10/lib/VBoxOGL.so)
==2225==    by 0x4AF3E45: crSPULoadChain (in /opt/VBoxGuestAdditions-3.2.10/lib/VBoxOGL.so)
==2225==    by 0x4ABEF43: stubInit (in /opt/VBoxGuestAdditions-3.2.10/lib/VBoxOGL.so)

It would be quite helpful, if valgrind was able to generate suppressions that take the origin tracking into account.
Comment 1 Phenom 2016-05-15 21:07:55 UTC
+1
Could be merged with this BR#280974
https://bugs.kde.org/show_bug.cgi?id=280974