Bug 93060 - Cast float->int leads to segmentation fault in compile-time
Summary: Cast float->int leads to segmentation fault in compile-time
Alias: None
Product: Beignet
Classification: Unclassified
Component: Beignet (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: ruiling
QA Contact:
Depends on:
Reported: 2015-11-21 22:17 UTC by pavelko95
Modified: 2018-10-12 21:23 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Description pavelko95 2015-11-21 22:17:01 UTC
Ok, I spent a lot of time to isolate the problem as much as possible. All components (loop, condition, casting and modification of `i`) are required to reproduce the bug.

Steps to Reproduce:
  1) Write kernel:
    kernel void evaluate(void) {
        float *stack[10];
        int i = 1;

        while (i)
            if ((int)(*stack[i]))
  2) Try to build the program

Actual Results:
  A segmentation fault occurs when trying to build program (`clBuildProgram(program, 0, NULL, NULL, NULL, NULL)`)

Expected Results:
  The program should be successfully compiled. Or, at least, should not sigfault.

Additional Information:
`dmesg` after couple runs:
  [72307.125321] ocl-bf[9586]: segfault at 7ff300000018 ip 00007ff3d25fac10 sp 00007fff77f05dd8 error 4 in libgbe.so[7ff3d21f0000+1a3c000]
  [72308.493759] ocl-bf[9601]: segfault at 0 ip 00007f7ea7850b14 sp 00007ffdb72e4fc0 error 4 in libgbe.so[7f7ea7442000+1a3c000]
  [72326.034834] ocl-bf[9635]: segfault at 7ffc101d2ff8 ip 00007fa682413ac4 sp 00007ffc101d3000 error 6 in libgbe.so[7fa682005000+1a3c000]

OS: Arch linux, 4.2.5-1, x86_64
Device: Intel HD 4400/Haswell i5
Beignet: 1.1.1-4 (AUR: https://aur.archlinux.org/packages/beignet/)
Comment 1 rongyang 2015-11-27 02:50:06 UTC
Assert when visit uninitialized pointer. Do you have other idea?
Comment 2 pavelko95 2015-11-27 06:49:59 UTC
(In reply to rongyang from comment #1)
> Assert when visit uninitialized pointer. Do you have other idea?

There is something strange:
  float a = 10.; float *stack[10] = {&a};  // sigfault
  float a = 10.; float *stack[10] = {&a, &a, &a, &a};  // sigfault
  float a = 10.; float *stack[10] = {&a, &a, &a, &a, &a};  // ok
  float *stack[2];  // sigfault
  float *stack[1];  // ok
  float a; float *stack[2] = {&a};  // ok
Comment 3 ruiling 2015-11-27 08:49:00 UTC
I take a quick look. it is related to storing pointers to private array.
Gen hardware does not support accessing random address. it only support memory read/write through a surface index. so when declaring a private array of pointers, we need to analyze where it is storing pointers into the pointer array. the bug is related to analyzing the pointer's surface index in llvm_gen_backend.cpp. I will take a further look to see how to fix it.
Comment 4 ruiling 2016-07-18 03:18:26 UTC
I am sorry for so late fix because of working on ocl 2.0 development. I finally make some time to fix it:
Comment 5 GitLab Migration User 2018-10-12 21:23:29 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/beignet/beignet/issues/17.

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.