0

When I run valgrind on my software it gives a condition jump or move depends on uninitialised value(s) error. The output from valgrind is as follows:

==871== Thread 4:
==871== Conditional jump or move depends on uninitialised value(s)
==871==    at 0x722E320: gcoHAL_ConstructEx (in /usr/lib/libGAL.so)
==871==    by 0x7391997: gcoOS_GetTLS (in /usr/lib/libGAL.so)
==871==    by 0x72375AF: gcoHAL_SetHardwareType (in /usr/lib/libGAL.so)
==871==    by 0x48BB1BF: ??? (in /usr/lib/libEGL.so.1.5.0)
==871==    by 0x48AF0E3: eglInitialize (in /usr/lib/libEGL.so.1.5.0)
==871==    by 0x12815B: egl_init (egl.c:80)
==871==    by 0x126E23: GRAPH_process (graphics.c:143)
==871==    by 0x70DFF57: start_thread (pthread_create.c:442)
==871==    by 0x714749B: thread_start (clone.S:79)
==871==  Uninitialised value was created by a stack allocation
==871==    at 0x722DD84: gcoHAL_ConstructEx (in /usr/lib/libGAL.so)
==871== 
==871== Conditional jump or move depends on uninitialised value(s)
==871==    at 0x722E348: gcoHAL_ConstructEx (in /usr/lib/libGAL.so)
==871==    by 0x7391997: gcoOS_GetTLS (in /usr/lib/libGAL.so)
==871==    by 0x72375AF: gcoHAL_SetHardwareType (in /usr/lib/libGAL.so)
==871==    by 0x48BB1BF: ??? (in /usr/lib/libEGL.so.1.5.0)
==871==    by 0x48AF0E3: eglInitialize (in /usr/lib/libEGL.so.1.5.0)
==871==    by 0x12815B: egl_init (egl.c:80)
==871==    by 0x126E23: GRAPH_process (graphics.c:143)
==871==    by 0x70DFF57: start_thread (pthread_create.c:442)
==871==    by 0x714749B: thread_start (clone.S:79)
==871==  Uninitialised value was created by a stack allocation
==871==    at 0x722DD84: gcoHAL_ConstructEx (in /usr/lib/libGAL.so)
==871== 
==871== Conditional jump or move depends on uninitialised value(s)
==871==    at 0x722E358: gcoHAL_ConstructEx (in /usr/lib/libGAL.so)
==871==    by 0x7391997: gcoOS_GetTLS (in /usr/lib/libGAL.so)
==871==    by 0x72375AF: gcoHAL_SetHardwareType (in /usr/lib/libGAL.so)
==871==    by 0x48BB1BF: ??? (in /usr/lib/libEGL.so.1.5.0)
==871==    by 0x48AF0E3: eglInitialize (in /usr/lib/libEGL.so.1.5.0)
==871==    by 0x12815B: egl_init (egl.c:80)
==871==    by 0x126E23: GRAPH_process (graphics.c:143)
==871==    by 0x70DFF57: start_thread (pthread_create.c:442)
==871==    by 0x714749B: thread_start (clone.S:79)
==871==  Uninitialised value was created by a stack allocation
==871==    at 0x722DD84: gcoHAL_ConstructEx (in /usr/lib/libGAL.so)
==871== 
==871== Conditional jump or move depends on uninitialised value(s)
==871==    at 0x722E3B4: gcoHAL_ConstructEx (in /usr/lib/libGAL.so)
==871==    by 0x7391997: gcoOS_GetTLS (in /usr/lib/libGAL.so)
==871==    by 0x72375AF: gcoHAL_SetHardwareType (in /usr/lib/libGAL.so)
==871==    by 0x48BB1BF: ??? (in /usr/lib/libEGL.so.1.5.0)
==871==    by 0x48AF0E3: eglInitialize (in /usr/lib/libEGL.so.1.5.0)
==871==    by 0x12815B: egl_init (egl.c:80)
==871==    by 0x126E23: GRAPH_process (graphics.c:143)
==871==    by 0x70DFF57: start_thread (pthread_create.c:442)
==871==    by 0x714749B: thread_start (clone.S:79)
==871==  Uninitialised value was created by a stack allocation
==871==    at 0x722DD84: gcoHAL_ConstructEx (in /usr/lib/libGAL.so)

The code runs fine it doesn't crash or give any warnings. The code valgrind is referring to is bellow:

void egl_init(s_egl *p_egl_param, struct wl_display *wayl_display)
{
    EGLint major = 0;
    EGLint minor = 0;
    EGLDisplay egl_display = NULL;

    PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL;
    get_platform_display = (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
    ASSERT(get_platform_display == NULL, "EGL: Failed to get platform display extension\n");

    egl_display = get_platform_display(EGL_PLATFORM_WAYLAND_KHR, wayl_display, config_attribs);
    ASSERT(!egl_display, "EGL: Failed to get platform display from wayland");

    if (egl_display)
    {
    --> error = eglInitialize(egl_display, &major, &minor);
        ASSERT(error != EGL_TRUE, "EGL: Failed to Initilize EGLDisplay");
        .
        .
        .
}

So I followed this stackoverflow thread to also initialize the structs before passing them as thread arguments to pthread_create()

#ifdef _MAIN_
#define EXTERN
#define INITIALIZE(...)        = __VA_ARGS__
#else
#define EXTERN extern
#define INITIALIZE(...)        /* nothing */
#endif /* DEFINE_VARIABLES */

EXTERN s_wayl Wayl_param INITIALIZE({0});
EXTERN s_egl Egl_param INITIALIZE({0});

I have tried my best to explain the problem I hope, Any help would be greatly appreciated.

Shaswath
  • 1
  • 1
  • It seems like it isn't inside your code, so maybe you can't do anything about it. There could be a bug in the library, but the library still *works*, so ehhh – user253751 May 10 '23 at 15:54
  • is the wayl_display fully initialized? – user253751 May 10 '23 at 15:54
  • You appear to be trying to use preprocessor trickery to declare / define external variables appropriately across multiple translation units of your program. I don't particularly care for that approach, and it comes with some gotchas. One of them is that for this particular trick to work, there must be exactly one translation unit (maybe the one containing your `main()` function) that defines macro `_MAIN_` , and that definition must appear *before* the `#include` directive for the header containing the code given at the end of the question. – John Bollinger May 10 '23 at 18:18
  • @user253751 Yes the wayl_display is initialized and I can do wl_display_roundtrip() without any issues. – Shaswath May 10 '23 at 20:16
  • @JohnBollinger Yes indeed the macro ``_MAIN_`` is defined in my `main()` before all the `#include`. – Shaswath May 10 '23 at 20:21
  • It looks like an issue in `libGAL`. It may be harmless, or it may reflect a *bona fide* flaw. The developers of that library are probably the ones best positioned to check it out. – John Bollinger May 10 '23 at 20:49
  • Can you install a debuginfo package for libGAL? It does look like a bug in the library - reading an uninitialized local variable. – Paul Floyd May 11 '23 at 12:34

0 Answers0