Bug 88957 - clinfo crashes in beignet on unsupported GPU
Summary: clinfo crashes in beignet on unsupported GPU
Alias: None
Product: Beignet
Classification: Unclassified
Component: Beignet (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) FreeBSD
: medium normal
Assignee: Zhigang Gong
QA Contact:
Depends on:
Reported: 2015-02-03 22:46 UTC by Koop Mast
Modified: 2015-02-06 08:31 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:

Return when no supported GPU is detected (752 bytes, patch)
2015-02-03 22:46 UTC, Koop Mast
Details | Splinter Review

Description Koop Mast 2015-02-03 22:46:14 UTC
Created attachment 113138 [details] [review]
Return when no supported GPU is detected

When running clinfo with Beignet on a not-supported Sandybridge system (according to line 497 from src/cl_device_id.c). 

clinfo crashes with the following stack trace below. This is because on not-supported the ret value in cl_get_gt_device() stays NULL. After line 513 the code assumes ret is populated.

Starting program: /usr/local/bin/clinfo 
[New Thread 80140c400 (LWP 100228)]
Number of platforms                               1
  Platform Name                                   Intel Gen OCL Driver
  Platform Vendor                                 Intel
  Platform Version                                OpenCL 1.2 beignet 1.0
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_icd
  Platform Extensions function suffix             Intel

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 80140c400 (LWP 100228)]
0x000000080182e2d4 in cl_get_gt_device ()
    at /home/kwm/sources/freebsd/freebsd-ports-graphics/lang/beignet/work/beignet/src/cl_device_id.c:526
526	      ret->host_unified_memory = CL_FALSE;
(gdb) bt full
#0  0x000000080182e2d4 in cl_get_gt_device ()
    at /home/kwm/sources/freebsd/freebsd-ports-graphics/lang/beignet/work/beignet/src/cl_device_id.c:526
        bo = 0x0
        ret = 0x0
        device_id = 278
        device = 0x0
        dummy = 0x801407080
        bufmgr = 0x8014ac600
        sz = 4096
        host_ptr = 0x801478000
        mib = {54356151, 8}
        totalram = 140737488348320
        len = 34380760064
        two_gb = 1
#1  0x000000080182e4e0 in cl_get_device_ids (
    platform=0x801a6c330 <intel_platform_data>, device_type=4294967295, 
    num_entries=0, devices=0x0, num_devices=0x80146ec50)
    at /home/kwm/sources/freebsd/freebsd-ports-graphics/lang/beignet/work/beignet/src/cl_device_id.c:575
        device = 0x7fffffffe550
#2  0x000000080180ad12 in clGetDeviceIDs (
    platform=0x801a6c330 <intel_platform_data>, device_type=4294967295, 
---Type <return> to continue, or q <return> to quit---
    num_entries=0, devices=0x0, num_devices=0x80146ec50)
    at /home/kwm/sources/freebsd/freebsd-ports-graphics/lang/beignet/work/beignet/src/cl_api.c:229
        err = 0
#3  0x0000000800836610 in clGetDeviceIDs (
    platform=0x801a6c330 <intel_platform_data>, device_type=4294967295, 
    num_entries=0, devices=0x0, num_devices=0x80146ec50)
    at ocl_icd_loader_gen.c:57
        ret = -1
#4  0x0000000000401fbe in printPlatformInfo (p=0) at src/clinfo.c:367
        pid = 0x801a6c330 <intel_platform_data>
        len = 5
        pinfo_checks = {has_khr_icd = 1}
#5  0x0000000000409b67 in main (argc=1, argv=0x7fffffffe758)
    at src/clinfo.c:2383
        p = 0
        d = 6368704
        device = 0x1
        a = 1
        show_offline = 0
Comment 1 Zhigang Gong 2015-02-06 08:31:54 UTC
Thanks for reporting the bug. It should be fixed by:

commit e953dbb1ec80e6939100c9b124a5e737fc027983
Author: Zhigang Gong <zhigang.gong@intel.com>
Date:   Fri Feb 6 14:26:02 2015 +0800

    runtime: fix a potential null pointer dereference.

    Signed-off-by: Zhigang Gong <zhigang.gong@intel.com>
    Reviewed-by: Xionghu Luo <xionghu.luo@intel.com>

The patch has been pushed to both master branch and Release_v1.0 branch.

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.