Bug 98886 - Segfault on clBuildProgram with stack trace pointing inside code generator
Summary: Segfault on clBuildProgram with stack trace pointing inside code generator
Status: RESOLVED MOVED
Alias: None
Product: Beignet
Classification: Unclassified
Component: Beignet (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Zhigang Gong
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-28 13:06 UTC by Troels Henriksen
Modified: 2018-10-12 21:24 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
The offending kernel (104.41 KB, text/plain)
2016-11-28 13:06 UTC, Troels Henriksen
Details
Driver program (1.26 KB, text/plain)
2016-11-28 13:07 UTC, Troels Henriksen
Details

Description Troels Henriksen 2016-11-28 13:06:36 UTC
Created attachment 128236 [details]
The offending kernel

Hi, I have a (rather monstrously large, sorry) kernel that crashes when I try to compile it using Beignet.  I have tried the Git version as of commit 75b6f3802171da72251885947bb196b64d38a99d, which also fails.

I have attached the kernel as well as a quick-and-dirty driver program to demonstrate the issue.  Using GDB, I get the following backtrace:

#0  0x00002aaab092c02f in gbe::GenWriter::emitMovForPHI (this=this@entry=0x555555cb4140, curr=curr@entry=0x555555a141e0, succ=<optimized out>)
    at /home/athas/repos/beignet/backend/src/llvm/llvm_gen_backend.cpp:2030
#1  0x00002aaab093a916 in gbe::GenWriter::emitBranchInst (this=this@entry=0x555555cb4140, I=...) at /home/athas/repos/beignet/backend/src/llvm/llvm_gen_backend.cpp:3679
#2  0x00002aaab093b139 in gbe::GenWriter::visitBranchInst (I=..., this=0x555555cb4140) at /home/athas/repos/beignet/backend/src/llvm/llvm_gen_backend.cpp:721
#3  llvm::InstVisitor<gbe::GenWriter, void>::visitBr (I=..., this=0x555555cb4140) at /usr/lib/llvm-3.5/include/llvm/IR/Instruction.def:98
#4  llvm::InstVisitor<gbe::GenWriter, void>::visit (I=..., this=<optimized out>) at /usr/lib/llvm-3.5/include/llvm/IR/Instruction.def:98
#5  gbe::GenWriter::emitBasicBlock (this=this@entry=0x555555cb4140, BB=BB@entry=0x555555a141e0) at /home/athas/repos/beignet/backend/src/llvm/llvm_gen_backend.cpp:2021
#6  0x00002aaab093c2ab in gbe::GenWriter::emitFunction (this=this@entry=0x555555cb4140, F=...) at /home/athas/repos/beignet/backend/src/llvm/llvm_gen_backend.cpp:3193
#7  0x00002aaab09441aa in gbe::GenWriter::runOnFunction (this=0x555555cb4140, F=...) at /home/athas/repos/beignet/backend/src/llvm/llvm_gen_backend.cpp:618
#8  0x00002aaab1867d97 in llvm::FPPassManager::runOnFunction(llvm::Function&) () from /usr/local/lib/beignet//libgbe.so
#9  0x00002aaab16790d8 in (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) () from /usr/local/lib/beignet//libgbe.so
#10 0x00002aaab18682dc in llvm::legacy::PassManagerImpl::run(llvm::Module&) () from /usr/local/lib/beignet//libgbe.so
#11 0x00002aaab0976723 in gbe::llvmToGen (unit=..., fileName=fileName@entry=0x0, module=module@entry=0x55555585ec40, optLevel=optLevel@entry=1, strictMath=strictMath@entry=true, 
    profiling=0, errors="") at /home/athas/repos/beignet/backend/src/llvm/llvm_to_gen.cpp:397
#12 0x00002aaab08ef84f in gbe::Program::buildFromLLVMFile (this=this@entry=0x555555c9ed70, fileName=fileName@entry=0x0, module=module@entry=0x55555585ec40, error="", 
    optLevel=optLevel@entry=1) at /home/athas/repos/beignet/backend/src/backend/program.cpp:144
#13 0x00002aaab0a4cd15 in gbe::genProgramNewFromLLVM (deviceID=5654, fileName=0x0, module=0x55555585ec40, llvm_ctx=0x555555c98640, asm_file_name=<optimized out>, stringSize=1048576, 
    err=0x55555585f5a0 "", errSize=0x555555ca4600, optLevel=1, options=0x555555554c87 "") at /home/athas/repos/beignet/backend/src/backend/gen_program.cpp:457
#14 0x00002aaab08fd4cb in gbe::programNewFromSource (deviceID=5654, source=<optimized out>, stringSize=1048576, options=0x555555554c87 "", err=0x55555585f5a0 "", errSize=0x555555ca4600)
    at /home/athas/repos/beignet/backend/src/backend/program.cpp:1082
#15 0x00002aaaab493b14 in cl_program_build (p=p@entry=0x555555ca44f0, options=0x555555554c87 "") at /home/athas/repos/beignet/src/cl_program.c:625
#16 0x00002aaaab48a192 in clBuildProgram (program=0x555555ca44f0, num_devices=<optimized out>, device_list=<optimized out>, options=<optimized out>, pfn_notify=0x0, user_data=0x0)
    at /home/athas/repos/beignet/src/cl_api.c:1358
#17 0x0000555555554ba3 in main () at crash.c:38
Comment 1 Troels Henriksen 2016-11-28 13:07:06 UTC
Created attachment 128237 [details]
Driver program
Comment 2 Xiuli Pan 2016-12-01 03:03:33 UTC
Hi Troels,

The kernel is indeed very big, I will try to build it and find if I will meet the same problem. Could you also provide the LLVM version your are using?

Thanks
Xiuli
Comment 3 Troels Henriksen 2016-12-01 06:40:33 UTC
I have some more information.  First, the kernel works using the version of Beignet in Debian's repositories (version 1.2.1-1).  It is quite possible that I just screwed up building Beignet from Git.

I have several versions of LLVM installed (3.5, 3.6, 3.7, and 3.8).  How can I see which version Beignet is built against?

Sorry for the large size (this is generated code).  I tried cutting it down, but I am pretty sure the bug is related to the giant branch near the end, so the bug disappeared if I removed too much of it.
Comment 4 Xiuli Pan 2016-12-05 03:41:43 UTC
I tried to build the kernel on my machine with llvm 3.6 and git master and did not find the same bug you meet.
Could you check the llvm version in your CMakeCache.txt and the log with
"export OCL_OUTPUT_LLVM_BEFORE_LINK=1" to see if the llvm version is the same and which llvm you are actually using.
Comment 5 Troels Henriksen 2016-12-06 06:17:35 UTC
According to CMakeCache.txt I am using LLVM 3.5.  After upgrading to LLVM 3.7, it seems to work, so this must be an LLVM bug.  Sorry for the noise.
Comment 6 GitLab Migration User 2018-10-12 21:24:38 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/33.


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.