jrprice / Oclgrind

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

Segmentation fault in simple program if ICD file is in /etc/OpenCL/vendors #136

Closed PhilippWph closed 5 years ago

PhilippWph commented 7 years ago

Hello @jrprice, I experience a segmentation fault when I use the ICD file in /etc/OpenCL/vendors. My program works if I use oclgrind directly. First of all some facts:

  1. I use an Ubuntu Linux 16.04 running in a VMWare virtual machine
  2. I installed the following Ubuntu packages:
  3. I created the ICD file with the following content /usr/lib/oclgrind/liboclgrind-rt.so
  4. Executing clinfo works, in both cases this means with the ICD file in /etc/OpenCL/vendors as well as by using oclgrind directly.
  5. Executing my program results in a segmentation fault. Here is the gdb backtrace:
    #0  0x0000000000000000 in ?? ()
    #1  0x00007ffff7902dc3 in std::thread::_M_start_thread(std::shared_ptr<std::thread::_Impl_base>, void (*)()) ()
    from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    #2  0x00007ffff5550844 in oclgrind::KernelInvocation::run() () from /usr/lib/x86_64-linux-gnu/liboclgrind-15.5.so
    #3  0x00007ffff5550af1 in oclgrind::KernelInvocation::run(oclgrind::Context const*, oclgrind::Kernel*, unsigned int, oclgrind::_Size3_, oclgrind::_Size3_, oclgrind::_Size3_) () from /usr/lib/x86_64-linux-gnu/liboclgrind-15.5.so
    #4  0x00007ffff5559dc2 in oclgrind::Queue::executeKernel(oclgrind::Queue::KernelCommand*) ()
    from /usr/lib/x86_64-linux-gnu/liboclgrind-15.5.so
    #5  0x00007ffff555a15d in oclgrind::Queue::update() () from /usr/lib/x86_64-linux-gnu/liboclgrind-15.5.so
    #6  0x00007ffff6b4f320 in clWaitForEvents () from /usr/lib/oclgrind/liboclgrind-rt.so
    #7  0x000000000040435b in cl::Event::wait (this=0x7fffffffd980) at /usr/include/CL/cl2.hpp:3008
    #8  0x0000000000403229 in main () at VectorAddition.cpp:358
  6. Removing the ICD file (from /etc/OpenCL/vendors/) and calling my program with oclgrind works.

Here is a small walkthrough through may program (VectorAddition, it calculates simply a+b=c for vectors):

Please let me know if I can provide you with any further information. For me the usage of oclgrind directly is fine. However it would be nice if the ICD file solution would work. My primary concern is that I want to develop and debug (the host code) from Eclipse C++. I was able to configure a run configuration but did not manage to create a debug configuration. So if you know a possibility for a gdb-based Eclipse debug configuration this would also solve this issue for me.

Best regards, viswph

jrprice commented 7 years ago

I'm not sure I'd expect this to work at all with the Ubuntu/Debian package, since it only provides liboclgrind-rt.so and not liboclgrind-rt-icd.so which has the ICD compatible interface. You could try downloading the prebuilt binaries from the GitHub releases page which does provide the liboclgrind-rt-icd.so library, but I haven't tested the ICD interface with that lately.

PhilippWph commented 7 years ago

Thanks for the fast reply. I tried to use the binary (liboclgrind-rt-icd.so) and created an ICD file that directs to this library. However then no platform is detected at all (in my program and in clinfo).

How do you debug your host code? Using oclgrind in Eclipse is not a big issue for me, however I would like to use Eclipse to debug the host code (only).

jrprice commented 7 years ago

Weird, I get the same thing (no platforms) if I use the Ubuntu-provided ICD loader (ocl-icd-libopencl1), but if I use the official Khronos ICD loader it works just fine. I'll keep digging.

jrprice commented 5 years ago

I believe the issue with Oclgrind not showing up with the Ubuntu provided ICD loader (ocl-icd) should have been fixed via #161.