Bug 95136

Summary: SIGSEGV in clReleaseDevice / cmrt_destroy_device
Product: Beignet Reporter: Andreas Reis <andreas.reis>
Component: BeignetAssignee: Guo Yejun <yejun.guo>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
i915 platform: i915 features:
Attachments: testcase
utest log

Description Andreas Reis 2016-04-25 17:37:10 UTC
Created attachment 123255 [details]

cmrt 2b31a1a
beignet b39d875
Haswell GT2 (4770)
kernel 4.6-rc5
ocl-icd 2.2.9

All compiled with gcc 5.3.1 (20160412) + debug flag / cmake option.

Running the attached source yields

#0  0x0000000000000000 in ?? ()
#1  0x00007ffff546d5b2 in cmrt_destroy_device (device=0x7ffff56a2480 <intel_hsw_gt2_device>) at beignet/src/cl_cmrt.cpp:101
#2  0x00007ffff54314fd in clReleaseDevice (device=0x7ffff56a2480 <intel_hsw_gt2_device>) at beignet/src/cl_api.c:282
#3  0x00007ffff79ab247 in clReleaseDevice (device=0x7ffff56a2480 <intel_hsw_gt2_device>) at ocl_icd_loader_gen.c:1154
#4  0x0000555555555840 in cl::detail::ReferenceHandler<_cl_device_id*>::release (device=0x7ffff56a2480 <intel_hsw_gt2_device>) at /usr/include/CL/cl.hpp:1573
#5  0x0000555555555ae8 in cl::detail::Wrapper<_cl_device_id*>::release (this=0x7fffffffcfa0) at /usr/include/CL/cl.hpp:1861
#6  0x0000555555555987 in cl::detail::Wrapper<_cl_device_id*>::~Wrapper (this=0x7fffffffcfa0, __in_chrg=<optimized out>) at /usr/include/CL/cl.hpp:1810
#7  0x0000555555555ff7 in cl::Device::~Device (this=0x7fffffffcfa0, __in_chrg=<optimized out>) at /usr/include/CL/cl.hpp:1907
#8  0x00005555555554bb in main () at test.cpp:14

No segfault with intel-opencl-runtime 16.1.
Comment 1 Andreas Reis 2016-04-26 14:28:21 UTC
Hardly relevant but: I patched the kernel with the shared local memory patch (the variable name is no longer "flags" but "dispatch_flags").

Apart from the patch, the freedesktop wiki page for Beignet might also need an update since it mentions that the cause was supposed to be "fixed in Linux 4.2", but that doesn't appear to actually be the case?
Comment 2 rongyang 2016-04-27 06:39:51 UTC
After Linux 4.2, kernel enable ppgtt by default and will set the secure flag after command parser, so needn't this patch.

Can you pass all beignet utest without shared local memory patch?

Yang Rong
Comment 3 Andreas Reis 2016-04-27 08:57:40 UTC
Created attachment 123295 [details]
utest log

Seems the patch indeed makes no difference anymore. Attached is the utest log – all pass except for runtime_cmrt.
Comment 4 Andreas Reis 2016-04-27 09:01:27 UTC
Alright, it's a cmrt issue. Recompiled beignet with cmrt 1.0.5 rather than git (d'uh) and it seems to work.
Comment 5 Andreas Reis 2016-04-27 10:44:39 UTC

If the cmrt present at beignet's compilation has this commit (a small change to cmrt's pkgconfig file) applied, the segfault will occur. IOW, if it was reverted before compilation no crash occurs.

No apparent effect if beignet is run afterwards with a cmrt that has it applied.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.