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.