jrprice / Oclgrind

An OpenCL device simulator and debugger
Other
346 stars 63 forks source link

clCreateProgramWithBinary(): Uninitialised value in Program class #169

Closed nunofachada closed 5 years ago

nunofachada commented 5 years ago

When creating a program from binary with clCreateProgramWithBinary() the m_requiresUniformWorkGroups member variable is not initialized. This causes "Conditional jump or move depends on uninitialised value(s)" error in Valgrind here and here.

How could this be solved?

Thanks

jrprice commented 5 years ago

I've reworked the way this is handled to make it a property of the kernel rather than the program, and we're now determining it based on the LLVM function attributes rather than the compiler flags, which addresses this issue (and some others as well).

nunofachada commented 5 years ago

Thanks! Those issues were solved, but one of them moved from Program to Kernel (see output below). I describe this in more detail in PR #171, which also contains a potential, somewhat naive solution.

==17305== Memcheck, a memory error detector
==17305== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==17305== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==17305== Command: ./tests/lib/test_program
==17305== 
/wrappers/program/create-info-destroy: ==17305== Conditional jump or move depends on uninitialised value(s)
==17305==    at 0x61CB4C1: oclgrind::KernelInvocation::KernelInvocation(oclgrind::Context const*, oclgrind::Kernel const*, unsigned int, oclgrind::Size3, oclgrind::Size3, oclgrind::Size3) (KernelInvocation.cpp:50)
==17305==    by 0x61CBA45: oclgrind::KernelInvocation::run(oclgrind::Context const*, oclgrind::Kernel*, unsigned int, oclgrind::Size3, oclgrind::Size3, oclgrind::Size3) (KernelInvocation.cpp:153)
==17305==    by 0x61EF272: oclgrind::Queue::executeKernel(oclgrind::Queue::KernelCommand*) (Queue.cpp:110)
==17305==    by 0x61EF80E: oclgrind::Queue::update() (Queue.cpp:252)
==17305==    by 0x4E8E292: clWaitForEvents (runtime.cpp:3279)
==17305==    by 0x50DC66B: ccl_event_wait (ccl_event_wrapper.c:824)
==17305==    by 0x40620B: create_info_destroy_test (test_program.c:552)
==17305==    by 0x5364CC9: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.5600.4)
==17305==    by 0x5364BFA: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.5600.4)
==17305==    by 0x5364BFA: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.5600.4)
==17305==    by 0x5364EA1: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.5600.4)
==17305==    by 0x5364EC0: g_test_run (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.5600.4)
==17305==  Uninitialised value was created by a heap allocation
==17305==    at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==17305==    by 0x4E98325: clEnqueueNDRangeKernel (runtime.cpp:4997)
==17305==    by 0x50D31E3: ccl_kernel_enqueue_ndrange (ccl_kernel_wrapper.c:432)
==17305==    by 0x50D397A: ccl_kernel_set_args_and_enqueue_ndrange_v (ccl_kernel_wrapper.c:656)
==17305==    by 0x50D826F: ccl_program_enqueue_kernel_v (ccl_program_wrapper.c:1665)
==17305==    by 0x406008: create_info_destroy_test (test_program.c:528)
==17305==    by 0x5364CC9: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.5600.4)
==17305==    by 0x5364BFA: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.5600.4)
==17305==    by 0x5364BFA: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.5600.4)
==17305==    by 0x5364EA1: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.5600.4)
==17305==    by 0x5364EC0: g_test_run (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.5600.4)
==17305==    by 0x401FCC: main (test_program.c:806)
==17305== 
OK
/wrappers/program/ref-unref: OK
/wrappers/program/compile-link: OK
==17305== 
==17305== HEAP SUMMARY:
==17305==     in use at exit: 80,948 bytes in 910 blocks
==17305==   total heap usage: 23,807 allocs, 22,897 frees, 14,163,394 bytes allocated
==17305== 
==17305== LEAK SUMMARY:
==17305==    definitely lost: 0 bytes in 0 blocks
==17305==    indirectly lost: 0 bytes in 0 blocks
==17305==      possibly lost: 0 bytes in 0 blocks
==17305==    still reachable: 80,948 bytes in 910 blocks
==17305==         suppressed: 0 bytes in 0 blocks
==17305== Reachable blocks (those to which a pointer was found) are not shown.
==17305== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==17305== 
==17305== For counts of detected and suppressed errors, rerun with: -v
==17305== ERROR SUMMARY: 2 errors from 1 contexts (suppressed: 0 from 0)