Valgrind reports error with Linux shared library

Valgrind reports error with Linux shared library

Hello all,

I modified the BitonicSort program to run on Linux. While the program worked correctly, it would crash when exiting so I used Valgrind to debug. I have since switched to using the C++ bindings but these problems exist in both cases. The first problem is while creating a cl::Context object I get messages about an uninitialized value being used in the function below. Fortunately the debug info was left in.

std::vector<cl::Device> devices;
thisContext = cl::Context(devices,context_properties,NULL,NULL,&result);
if(result != CL_SUCCESS)
printf("ERROR: cl::Context() failed with %d\n",result);
return -1;
printf("INFO: cl::Context() created\n");

==2875== Conditional jump or move depends on uninitialised value(s)
==2875== at 0x6F6B2A2: Intel::OpenCL::DeviceBackend::Utils::CPUDetect::CPUDetect() (in /usr/lib64/OpenCL/vendors/intel/
==2875== by 0x6F6B3FF: global constructors keyed to CPUDetect.cpp (in /usr/lib64/OpenCL/vendors/intel/
==2875== by 0x76C1DF5: ??? (in /usr/lib64/OpenCL/vendors/intel/
==2875== by 0x6F18602: ??? (in /usr/lib64/OpenCL/vendors/intel/
==2875== Uninitialised value was created by a stack allocation
==2875== at 0x6F6B260: Intel::OpenCL::DeviceBackend::Utils::CPUDetect::CPUDetect() (in /usr/lib64/OpenCL/vendors/intel/

The second set of errors reports the following while running cl::Program::build().,NULL,NULL,NULL);

==2889== Conditional jump or move depends on uninitialised value(s)
==2889== at 0x4A091A9: __GI_strlen (mc_replace_strmem.c:404)
==2889== by 0x307A6853E5: strdup (in /usr/lib64/
==2889== by 0x57C24B2: Intel::OpenCL::Utils::CPUDetect::GetCPUInfo() (in /usr/lib64/OpenCL/vendors/intel/
==2889== by 0x57C2903: Intel::OpenCL::Utils::CPUDetect::GetInstance() (in /usr/lib64/OpenCL/vendors/intel/
==2889== by 0x57BD078: Intel::OpenCL::ClangFE::CompileTask::PrepareArgumentList(std::list<std::string, std::allocator<std::string> >&, std::list<std::string, std::allocator<std::string> >&, char const*) (in /usr/lib64/OpenCL/vendors/intel/
==2889== by 0x57BF059: Intel::OpenCL::ClangFE::CompileTask::Execute() (in /usr/lib64/OpenCL/vendors/intel/
==2889== by 0x3B1F20F689: Intel::OpenCL::TaskExecutor::execute_command(Intel::OpenCL::TaskExecutor::ITaskBase*) (in /usr/lib64/OpenCL/vendors/intel/
==2889== by 0x3B1F213810: Intel::OpenCL::TaskExecutor::in_order_executor_task::execute() (in /usr/lib64/OpenCL/vendors/intel/
==2889== by 0x3B1F6204FB: tbb::internal::custom_scheduler<tbb::internal::IntelSchedulerTraits>::local_wait_for_all(tbb::task&, tbb::task*) (custom_scheduler.h:441)
==2889== by 0x3B1F61D7D8: tbb::internal::arena::process(tbb::internal::generic_scheduler&) (arena.cpp:91)
==2889== by 0x3B1F61BC8A: tbb::internal::market::process(rml::job&) (market.cpp:385)
==2889== by 0x3B1F6192F6: tbb::internal::rml::private_worker::run() (private_server.cpp:255)
==2889== Uninitialised value was created by a stack allocation
==2889== at 0x307A2148E5: _dl_runtime_resolve (in /usr/lib64/

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.


Could you please attach a reproducer for this issue (modified BitonicSort, as well as makefile or compilation flags).


Compiled with 'clang++ -g -lOpenCL main.cpp'
Run with 'valgrind ./a.out'

I posted a cleaned-up single-file version. For me this crashes on exit, but doesn't when run through valgrind. Lines 136 and 167 have the function calls of interest. Algorithm otherwise executes correctly on a Core 2 Duo(P8400).

Running on Fedora 17
clang version 3.3 (trunk 171050), although it happens with gcc as well


Downloadtext/x-c++src bitonicsort.cxx3.24 KB
Downloadtext/x-c++src main.cpp7.08 KB

Leave a Comment

Please sign in to add a comment. Not a member? Join today