Bug 213732 - lang/beignet: crashes with some OpenCL apps
Summary: lang/beignet: crashes with some OpenCL apps
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-x11 (Nobody)
URL:
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2016-10-23 16:12 UTC by Jan Beich
Modified: 2017-03-25 12:31 UTC (History)
4 users (show)

See Also:
bugzilla: maintainer-feedback? (x11)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer 2016-10-23 16:12:46 UTC
I'm using drm-next-4.7 (rebased) + xserver-next. Either Beignet or drm-next-4.7 appears to have partially broken OpenCL implementation. Not sure if the issue affects the main tree but filing here for better visibility.

Let's prepare

  $ pkg install -qy beignet pocl waifu2x-converter-cpp ffmpeg
  $ fetch https://github.com/nagadomi/waifu2x/raw/master/images/miku_CC_BY-NC_noisy.jpg
  $ fetch http://demo-uhd3d.com/files/uhd4k/Samsung_UHD_7Wonders_of_the_World_Italy.ts


clinfo is a bit too verbose, here's what a typical app only cares about.

  $ waifu2x-converter-cpp --list-processor
     0: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz     (FMA       ): num_core=8
     1: Intel(R) HD Graphics Skylake Desktop GT2     (OpenCL    ): num_core=24
     2: pthread                                      (OpenCL    ): num_core=8
  Nothing to output !

or from under linuxulator

  $ waifu2x-converter-cpp --list-processor
     0: GeForce GT 640                               (CUDA      ): num_core=2
     1: GeForce GT 640                               (OpenCL    ): num_core=2
     2: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz     (FMA       ): num_core=8

POCL is good to check OpenCL on FreeBSD isn't broken elsewhere.

  $ waifu2x-converter-cpp --processor 2 -i miku_CC_BY-NC_noisy.jpg
  OpenCL: pthread
  start process block (0,0) ...
  Iteration #1(3->32)...(50.0566[ms], 9.04946[GFLOPS], 0.733174[GB/s])
  Iteration #2(32->32)...(143.36[ms], 33.7042[GFLOPS], 0.468114[GB/s])
  Iteration #3(32->64)...(271.268[ms], 35.6241[GFLOPS], 0.371084[GB/s])
  Iteration #4(64->64)...(671.44[ms], 28.7849[GFLOPS], 0.199895[GB/s])
  [...]

  $ waifu2x-converter-cpp --processor 1 -i miku_CC_BY-NC_noisy.jpg
  Unresolved symbol: _Z14__gen_ocl_fmaxff
  Aborting...
  Caller instruction:
    %call.i.630 = tail call float @_Z14__gen_ocl_fmaxff(float %add807, float 0.000000e+00) #6
  Callee function:

  ; Function Attrs: nounwind readnone
  declare spir_func float @_Z14__gen_ocl_fmaxff(float, float) #1

  Unresolved symbol: _Z14__gen_ocl_fminff
  Aborting...
  Caller instruction:
    %call.i.631 = tail call float @_Z14__gen_ocl_fminff(float %add807, float 0.000000e+00) #6
  Callee function:

  ; Function Attrs: nounwind readnone
  declare spir_func float @_Z14__gen_ocl_fminff(float, float) #1

  Unresolved symbol: _Z14__gen_ocl_fmaxff
  Aborting...
  Caller instruction:
    %call.i.632 = tail call float @_Z14__gen_ocl_fmaxff(float %add818, float 0.000000e+00) #6
  Callee function:

  ; Function Attrs: nounwind readnone
  declare spir_func float @_Z14__gen_ocl_fmaxff(float, float) #1

  Unresolved symbol: _Z14__gen_ocl_fminff
  Aborting...
  Caller instruction:
    %call.i.633 = tail call float @_Z14__gen_ocl_fminff(float %add818, float 0.000000e+00) #6
  Callee function:

  ; Function Attrs: nounwind readnone
  declare spir_func float @_Z14__gen_ocl_fminff(float, float) #1

  Unresolved symbol: _Z14__gen_ocl_fmaxff
  Aborting...
  Caller instruction:
    %call.i.634 = tail call float @_Z14__gen_ocl_fmaxff(float %add831, float 0.000000e+00) #6
  Callee function:

  ; Function Attrs: nounwind readnone
  declare spir_func float @_Z14__gen_ocl_fmaxff(float, float) #1

  Unresolved symbol: _Z14__gen_ocl_fminff
  Aborting...
  Caller instruction:
    %call.i.635 = tail call float @_Z14__gen_ocl_fminff(float %add831, float 0.000000e+00) #6
  Callee function:

  ; Function Attrs: nounwind readnone
  declare spir_func float @_Z14__gen_ocl_fminff(float, float) #1

  Unresolved symbol: _Z14__gen_ocl_fmaxff
  Aborting...
  Caller instruction:
    %call.i.636 = tail call float @_Z14__gen_ocl_fmaxff(float %add844, float 0.000000e+00) #6
  Callee function:

  ; Function Attrs: nounwind readnone
  declare spir_func float @_Z14__gen_ocl_fmaxff(float, float) #1

  Unresolved symbol: _Z14__gen_ocl_fminff
  Aborting...
  Caller instruction:
    %call.i.637 = tail call float @_Z14__gen_ocl_fminff(float %add844, float 0.000000e+00) #6
  Callee function:

  ; Function Attrs: nounwind readnone
  declare spir_func float @_Z14__gen_ocl_fminff(float, float) #1

  Unresolved symbol: _Z14__gen_ocl_fmaxff
  Aborting...
  Caller instruction:
    %call.i.638 = tail call float @_Z14__gen_ocl_fmaxff(float %add857, float 0.000000e+00) #6
  Callee function:

  ; Function Attrs: nounwind readnone
  declare spir_func float @_Z14__gen_ocl_fmaxff(float, float) #1

  Unresolved symbol: _Z14__gen_ocl_fminff
  Aborting...
  Caller instruction:
    %call.i.639 = tail call float @_Z14__gen_ocl_fminff(float %add857, float 0.000000e+00) #6
  Callee function:

  ; Function Attrs: nounwind readnone
  declare spir_func float @_Z14__gen_ocl_fminff(float, float) #1

  Unresolved symbol: _Z14__gen_ocl_fmaxff
  Aborting...
  Caller instruction:
    %call.i.640 = tail call float @_Z14__gen_ocl_fmaxff(float %add870, float 0.000000e+00) #6
  Callee function:

  ; Function Attrs: nounwind readnone
  declare spir_func float @_Z14__gen_ocl_fmaxff(float, float) #1

  Unresolved symbol: _Z14__gen_ocl_fminff
  Aborting...
  Caller instruction:
    %call.i.641 = tail call float @_Z14__gen_ocl_fminff(float %add870, float 0.000000e+00) #6
  Callee function:

  ; Function Attrs: nounwind readnone
  declare spir_func float @_Z14__gen_ocl_fminff(float, float) #1

  Unresolved symbol: _Z14__gen_ocl_fmaxff
  Aborting...
  Caller instruction:
    %call.i.642 = tail call float @_Z14__gen_ocl_fmaxff(float %add883, float 0.000000e+00) #6
  Callee function:

  ; Function Attrs: nounwind readnone
  declare spir_func float @_Z14__gen_ocl_fmaxff(float, float) #1

  Unresolved symbol: _Z14__gen_ocl_fminff
  Aborting...
  Caller instruction:
    %call.i.643 = tail call float @_Z14__gen_ocl_fminff(float %add883, float 0.000000e+00) #6
  Callee function:

  ; Function Attrs: nounwind readnone
  declare spir_func float @_Z14__gen_ocl_fminff(float, float) #1

  Unresolved symbol: _Z14__gen_ocl_fmaxff
  Aborting...
  Caller instruction:
    %call.i.644 = tail call float @_Z14__gen_ocl_fmaxff(float %add896, float 0.000000e+00) #6
  Callee function:

  ; Function Attrs: nounwind readnone
  declare spir_func float @_Z14__gen_ocl_fmaxff(float, float) #1

  Unresolved symbol: _Z14__gen_ocl_fminff
  Aborting...
  Caller instruction:
    %call.i.645 = tail call float @_Z14__gen_ocl_fminff(float %add896, float 0.000000e+00) #6
  Callee function:

  ; Function Attrs: nounwind readnone
  declare spir_func float @_Z14__gen_ocl_fminff(float, float) #1

  Unresolved symbol: _Z14__gen_ocl_fmaxff
  Aborting...
  Unresolved symbol: _Z14__gen_ocl_fminff
  Aborting...
  Unresolved symbol: _Z14__gen_ocl_fmaxff
  Aborting...
  Unresolved symbol: _Z14__gen_ocl_fminff
  Aborting...
  Unresolved symbol: _Z14__gen_ocl_fmaxff
  Aborting...
  Unresolved symbol: _Z14__gen_ocl_fminff
  Aborting...
  Unresolved symbol: _Z14__gen_ocl_fmaxff
  Aborting...
  Unresolved symbol: _Z14__gen_ocl_fminff
  Aborting...
  Unresolved symbol: _Z14__gen_ocl_fmaxff
  Aborting...
  Unresolved symbol: _Z14__gen_ocl_fminff
  Aborting...
  Unresolved symbol: _Z14__gen_ocl_fmaxff
  Aborting...
  Unresolved symbol: _Z14__gen_ocl_fminff
  Aborting...
  Unresolved symbol: _Z14__gen_ocl_fmaxff
  Aborting...
  Unresolved symbol: _Z14__gen_ocl_fminff
  Aborting...
  Unresolved symbol: _Z14__gen_ocl_fmaxff
  Aborting...
  Unresolved symbol: _Z14__gen_ocl_fminff
  Aborting...

  $ pkg install -qy beignet ffmpeg
  $ fetch http://demo-uhd3d.com/files/uhd4k/Samsung_UHD_7Wonders_of_the_World_Italy.ts
  $ ffmpeg -hide_banner -i /p/Samsung_UHD_7Wonders_of_the_World_Italy.ts -x264opts opencl:opencl-device=0 -codec:v libx264 -y /tmp/a.mp4
  [mpegts @ 0x80ac7a000] start time for stream 1 is not set in estimate_timings_from_pts
  [mpegts @ 0x80ac7a000] Could not find codec parameters for stream 1 (Audio: aac ([15][0][0][0] / 0x000F), 0 channels, fltp): unspecified sample rate
  Consider increasing the value for the 'analyzeduration' and 'probesize' options
  Input #0, mpegts, from '/p/Samsung_UHD_7Wonders_of_the_World_Italy.ts':
    Duration: 00:02:12.28, start: 1.050044, bitrate: 51922 kb/s
    Program 1
      Stream #0:0[0x101]: Video: hevc (Main 10) ([36][0][0][0] / 0x0024), yuv420p10le(tv), 3840x2160 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 59.94 tbc
      Stream #0:1[0x102](und): Audio: aac ([15][0][0][0] / 0x000F), 0 channels, fltp
  [libx264 @ 0x80ac18d00] using SAR=1/1
  [libx264 @ 0x80ac18d00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
  [libx264 @ 0x80ac18d00] OpenCL acceleration enabled with Intel Intel(R) HD Graphics Skylake Desktop GT2
  [libx264 @ 0x80ac18d00] Compiling OpenCL kernels...
  Unresolved symbol: _Z23__gen_ocl_write_imageui11ocl_image2dDv2_iDv4_j
  Aborting...
  Unresolved symbol: _Z23__gen_ocl_write_imageui11ocl_image2dDv2_iDv4_j
  Aborting...
  While deleting: <4 x i32> %
  Use still stuck around after Def is destroyed:  tail call void @_Z23__gen_ocl_write_imageui11ocl_image2dDv2_iDv4_j(%opencl.image2d_t.0 addrspace(1)* %fenc_img, <2 x i32> %vecinit6, <4 x i32> <badref>) #10
  Assertion failed: (use_empty() && "Uses remain when a value is destroyed!"), function ~Value, file /usr/ports/devel/llvm37/work/llvm-3.7.1.src/lib/IR/Value.cpp, line 82.
Comment 1 Jan Beich freebsd_committer 2016-10-23 16:37:13 UTC
One of graphics/piglit tests fails the same way as multimedia/libx264:

  $ /usr/local/lib/piglit/bin/cl-api-enqueue-fill-image
  ## Test: clEnqueueFillImage (/usr/ports/graphics/piglit/work/piglit-ca5350b4056ae63a93c4c207087b7634873b2ce2/tests/cl/api/enqueue-fill-image.c) ##

  # Running on:
  #   Platform: Intel Gen OCL Driver
  #   Device: Intel(R) HD Graphics Skylake Desktop GT2
  #   OpenCL version: 1.2
  Unresolved symbol: _Z22__gen_ocl_write_imagef11ocl_image2dDv2_iDv4_f
  Aborting...
  While deleting: <2 x i32> %
  Use still stuck around after Def is destroyed:  tail call void @_Z22__gen_ocl_write_imagef11ocl_image2dDv2_iDv4_f(%opencl.image2d_t.0 addrspace(1)* %image, <2 x i32> <badref>, <4 x float> %pattern) #6
  Assertion failed: (use_empty() && "Uses remain when a value is destroyed!"), function ~Value, file /usr/ports/devel/llvm37/work/llvm-3.7.1.src/lib/IR/Value.cpp, line 82.
Comment 2 Jan Beich freebsd_committer 2017-03-08 09:21:09 UTC
I can still reproduce on drm-next from 2017-03-07 (be99d136554) and beignet-1.3.0.

$ /usr/local/lib/piglit/bin/cl-api-enqueue-fill-image
## Test: clEnqueueFillImage (/wrkdirs/usr/ports/graphics/piglit/work/piglit-ca5350b4056ae63a93c4c207087b7634873b2ce2/tests/cl/api/enqueue-fill-image.c) ##

# Running on:
#   Platform: Intel Gen OCL Driver
#   Device: Intel(R) HD Graphics Skylake Desktop GT2
#   OpenCL version: 1.2
Unresolved symbol: _Z22__gen_ocl_write_imagef14ocl_image2d_woDv2_iDv4_f
Aborting...
While deleting: <2 x i32> %
Use still stuck around after Def is destroyed:  tail call void @_Z22__gen_ocl_write_imagef14ocl_image2d_woDv2_iDv4_f(%opencl.image2d_wo_t.0 addrspace(1)* %image, <2 x i32> <badref>, <4 x float> %pattern) #4
Assertion failed: (use_empty() && "Uses remain when a value is destroyed!"), function ~Value, file /tmp/a/overlay/ports/devel/llvm39/work/llvm-3.9.1.src/lib/IR/Value.cpp, line 85.

$ waifu2x-converter-cpp --processor 1 -i miku_CC_BY-NC_noisy.jpg
Unresolved symbol: _Z14__gen_ocl_fmaxff
Aborting...
[...]
Segmentation fault

* thread #1, stop reason = signal SIGSEGV: invalid address (fault address: 0xae40003)
    frame #0: 0x000000080dab7084 libgbe.so`llvm::LLVMContext::removeModule(llvm::Module*) + 4
libgbe.so`llvm::LLVMContext::removeModule:
->  0x80dab7084 <+4>: movq   (%rdi), %rdi
    0x80dab7087 <+7>: popq   %rbp
    0x80dab7088 <+8>: jmp    0x80db6a460               ; llvm::SmallPtrSetImplBase::erase_imp(void const*)
    0x80dab708d:      nop
(lldb) bt
* thread #1, stop reason = signal SIGSEGV: invalid address (fault address: 0xae40003)
  * frame #0: 0x000000080dab7084 libgbe.so`llvm::LLVMContext::removeModule(llvm::Module*) + 4
    frame #1: 0x000000080dae8cbf libgbe.so`llvm::Module::~Module(void) + 31
    frame #2: libgbe.so`gbe::Program::buildFromLLVMFile(this=0x000000080ae1fcb0, fileName=0x0000000000000000, module=0x000000080af42c00, error=0x00007fffffff4b48, optLevel=1) at program.cpp:177
    frame #3: libgbe.so`gbe::genProgramNewFromLLVM(deviceID=6418, fileName=0x0000000000000000, module=0x000000080af42c00, llvm_ctx=0x000000080ae4c460, asm_file_name=0x0000000000000000, stringSize=1048576, err="", errSize=0x000000080ae57368, optLevel=1, options="") at gen_program.cpp:459
    frame #4: libgbe.so`gbe::programNewFromSource(deviceID=6418, source="https://github.com/tanakamura/waifu2x-converter-cpp/blob/master/src/modelHandler_OpenCL.cl", stringSize=1048576, options="", err="", errSize=0x000000080ae57368) at program.cpp:1111
    frame #5: libcl.so`cl_program_build(p=0x000000080ae572a0, options="") at cl_program.c:625
    frame #6: libcl.so`clBuildProgram(program=0x000000080ae572a0, num_devices=1, device_list=0x00007fffffff5648, options="", pfn_notify=0x0000000000000000, user_data=0x0000000000000000) at cl_api.c:835
    frame #7: libOpenCL.so.1`clBuildProgram(program=0x000000080ae572a0, num_devices=1, device_list=0x00007fffffff5648, options="", pfn_notify=0x0000000000000000, user_data=0x0000000000000000) at ocl_icd_loader_gen.c:387
    frame #8: libw2xc.so`w2xc::initOpenCL(c=0x000000080ae5f0a0, env=0x000000080ae462f8, proc=0x000000080af29908) at modelHandler_OpenCL.cpp:361
    frame #9: libw2xc.so`::w2xconv_init_with_processor(processor_idx=1, nJob=8, enable_log=1) at w2xconv.cpp:379
    frame #10: waifu2x-converter-cpp`main(argc=5, argv=0x00007fffffffe3e0) at main.cpp:185
    frame #11: waifu2x-converter-cpp`_start(ap=<unavailable>, cleanup=<unavailable>) at crt1.c:72

$ ffmpeg -hide_banner -i Samsung_UHD_7Wonders_of_the_World_Italy.ts -x264opts opencl:opencl-device=0 -codec:v libx264 -y /tmp/a.mp4
[mpegts @ 0x80ac54000] start time for stream 1 is not set in estimate_timings_from_pts
[mpegts @ 0x80ac54000] Could not find codec parameters for stream 1 (Audio: aac ([15][0][0][0] / 0x000F), 0 channels, fltp): unspecified sample rate
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mpegts, from '/p/Samsung_UHD_7Wonders_of_the_World_Italy.ts':
  Duration: 00:02:12.28, start: 1.050044, bitrate: 51922 kb/s
  Program 1
    Stream #0:0[0x101]: Video: hevc (Main 10) ([36][0][0][0] / 0x0024), yuv420p10le(tv), 3840x2160 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x102](und): Audio: aac ([15][0][0][0] / 0x000F), 0 channels, fltp
[libx264 @ 0x80ac18d00] using SAR=1/1
[libx264 @ 0x80ac18d00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x80ac18d00] OpenCL acceleration enabled with Intel Intel(R) HD Graphics Skylake Desktop GT2
[libx264 @ 0x80ac18d00] Compiling OpenCL kernels...
Unresolved symbol: _Z23__gen_ocl_write_imageui14ocl_image2d_woDv2_iDv4_j
Aborting...
Unresolved symbol: _Z22__gen_ocl_read_imageui14ocl_image2d_ro11ocl_samplerDv2_fj
Aborting...
[...]
Segmentation fault

* thread #1, stop reason = signal SIGSEGV: invalid address (fault address: 0x18)
    frame #0: libgbe.so`llvm::Value::getValueID(this=0x0000000000000000) const at Value.h:425
   422    /// # the InstructionVal enumerator must be the highest valued enumerator in
   423    ///   the ValueTy enum.
   424    unsigned getValueID() const {
-> 425      return SubclassID;
   426    }
   427
   428    /// \brief Return the raw optional flags value contained in this value.
(lldb) bt
* thread #1, stop reason = signal SIGSEGV: invalid address (fault address: 0x18)
  * frame #0: libgbe.so`llvm::Value::getValueID(this=0x0000000000000000) const at Value.h:425
    frame #1: libgbe.so`llvm::isa_impl<llvm::Instruction, llvm::Value, void>::doit(Val=0x0000000000000000) at Value.h:734
    frame #2: libgbe.so`llvm::isa_impl_cl<llvm::Instruction, llvm::Value const*>::doit(Val=0x0000000000000000) at Casting.h:96
    frame #3: libgbe.so`llvm::isa_impl_wrap<llvm::Instruction, llvm::Value const*, llvm::Value const*>::doit(Val=0x00007fffffff6db0) at Casting.h:122
    frame #4: libgbe.so`llvm::isa_impl_wrap<llvm::Instruction, llvm::Value* const, llvm::Value const*>::doit(Val=0x00007fffffff6df8) at Casting.h:112
    frame #5: libgbe.so`bool llvm::isa<llvm::Instruction, llvm::Value*>(Val=0x00007fffffff6df8) at Casting.h:133
    frame #6: libgbe.so`llvm::cast_retty<llvm::Instruction, llvm::Value*>::ret_type llvm::dyn_cast<llvm::Instruction, llvm::Value>(Val=0x0000000000000000) at Casting.h:298
    frame #7: libgbe.so`gbe::Scalarize::scalarizeExtract(this=0x000000080ac5c7c0, extr=0x000000080b3517e0) at llvm_scalarize.cpp:824
    frame #8: libgbe.so`gbe::Scalarize::scalarize(this=0x000000080ac5c7c0, inst=0x000000080b3517e0) at llvm_scalarize.cpp:517
    frame #9: libgbe.so`gbe::Scalarize::runOnFunction(this=0x000000080ac5c7c0, F=0x000000080ba39848)at llvm_scalarize.cpp:905
    frame #10: 0x0000000850ec799c libgbe.so`llvm::FPPassManager::runOnFunction(llvm::Function&) + 540
    frame #11: 0x0000000850cb06b4 libgbe.so`(anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) + 1412
    frame #12: 0x0000000850ec815c libgbe.so`llvm::legacy::PassManagerImpl::run(llvm::Module&) + 988
    frame #13: libgbe.so`gbe::llvmToGen(unit=0x000000080dba6780, fileName=0x0000000000000000, module=0x000000080aff5300, optLevel=1, strictMath=true, profiling=0, errors=0x00007fffffff9748) at llvm_to_gen.cpp:409
    frame #14: libgbe.so`gbe::Program::buildFromLLVMFile(this=0x000000080adeb150, fileName=0x0000000000000000, module=0x000000080aff5f00, error=0x00007fffffff9748, optLevel=1) at program.cpp:146
    frame #15: libgbe.so`gbe::genProgramNewFromLLVM(deviceID=6418, fileName=0x0000000000000000, module=0x000000080aff5f00, llvm_ctx=0x000000080ac44568, asm_file_name=0x0000000000000000, stringSize=1048576, err="", errSize=0x000000080acd7fa8, optLevel=1, options="") at gen_program.cpp:459
    frame #16: libgbe.so`gbe::programNewFromSource(deviceID=6418, source="http://sprunge.us/iSib", stringSize=1048576, options="", err="", errSize=0x000000080acd7fa8)at program.cpp:1111
    frame #17: libcl.so`cl_program_build(p=0x000000080acd7ee0, options="") at cl_program.c:625
    frame #18: libcl.so`clBuildProgram(program=0x000000080acd7ee0, num_devices=1, device_list=0x000000080dbbd6b8, options="", pfn_notify=0x0000000000000000, user_data=0x0000000000000000) at cl_api.c:835
    frame #19: libOpenCL.so.1`clBuildProgram(program=0x000000080acd7ee0, num_devices=1, device_list=0x000000080dbbd6b8, options="", pfn_notify=0x0000000000000000, user_data=0x0000000000000000) at ocl_icd_loader_gen.c:387
    frame #20: libx264.so.148`x264_opencl_compile(h=0x000000080dbb1720) at opencl.c:277
    frame #21: libx264.so.148`x264_opencl_lookahead_alloc(h=0x000000080dbb1720) at opencl.c:363
    frame #22: libx264.so.148`x264_opencl_lookahead_init(h=0x000000080dbb1720) at opencl.c:543
    frame #23: libx264.so.148`x264_encoder_open_148(param=0x000000080ac55208) at encoder.c:1674
    frame #24: 0x000000080121e5ee libavcodec.so.57`X264_init + 4190
    frame #25: 0x00000008014b75d0 libavcodec.so.57`avcodec_open2 + 5072
    frame #26: 0x000000000022a498 ffmpeg`transcode + 4440
    frame #27: 0x0000000000228ac1 ffmpeg`main + 3169
    frame #28: ffmpeg`_start(ap=<unavailable>, cleanup=<unavailable>) at crt1.c:72
Comment 3 Xiuli Pan 2017-03-17 03:51:30 UTC
Hi,

I am Xiuli form the Beignet team and I have seen some patch to our mail-list and found there are some bugs here.

These bugs seems to be some conflict about the llvm version. LLVM has a mangle change in LLVM39, if you get some binary build with LLVM39 and have some lower verison CLANG when runing. There maybe some bugs like this.

So could you provide the clang -v output to check the LLVM version.

Thanks
Xiuli
Comment 4 Jan Beich freebsd_committer 2017-03-17 12:11:23 UTC
(In reply to Xiuli Pan from comment #3)
> These bugs seems to be some conflict about the llvm version. LLVM has a mangle
> change in LLVM39, if you get some binary build with LLVM39 and have some lower
> verison CLANG when runing. There maybe some bugs like this.

Thank you for the hint. Beignet works fine after a small fix[1] but I haven't tested much.

[1] https://lists.freedesktop.org/archives/beignet/2017-March/008702.html

> So could you provide the clang -v output to check the LLVM version.

FreeBSD has one Clang version in base and many more suffixed in ports/packages. lang/beignet port passes -DLLVM_CONFIG_EXECUTABLE=/usr/local/bin/llvm-config39 which ends up building some (but not all) files with clang39. However, even forcing to build everything with clang39 doesn't help.

$ clang -v
FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM 4.0.0)
Target: x86_64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin

$ clang39 -v
clang version 3.9.1 (tags/RELEASE_391/final)
Target: x86_64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/local/llvm39/bin
Comment 5 Xiuli Pan 2017-03-17 12:44:25 UTC
(In reply to Jan Beich (mail not working) from comment #4)
OK, it seems you have already root cause it, I will review you patch then.

Thanks
Xiuli
Comment 6 Jan Beich freebsd_committer 2017-03-22 06:38:50 UTC
libcxxrt behavior doesn't even match libcxxabi (from LLVM). I've filed a bug: https://github.com/pathscale/libcxxrt/issues/46
Comment 7 commit-hook freebsd_committer 2017-03-22 21:46:47 UTC
A commit references this bug:

Author: dim
Date: Wed Mar 22 21:45:42 UTC 2017
New revision: 315745
URL: https://svnweb.freebsd.org/changeset/base/315745

Log:
  Cherry-pick libcxxrt commit 8a853717e61d5d55cbdf74d9d0a7545da5d5ff92:

  Author: David Chisnall <theraven@FreeBSD.org>
  Date:   Wed Mar 22 12:27:08 2017 +0000

      Simplify some code.

      realloc() with a null pointer is equivalent to malloc, so we don't need
      to handle the two cases independently.

      Fixes #46

  This should help with lang/beignet and other programs, which expect
  __cxa_demangle(name, NULL, NULL, &status) to return zero in status.

  PR:		213732
  MFC after:	3 days

Changes:
  head/contrib/libcxxrt/typeinfo.cc
Comment 8 Dimitry Andric freebsd_committer 2017-03-22 21:48:53 UTC
I will close this after r315745 has been MFCd.
Comment 9 commit-hook freebsd_committer 2017-03-25 12:30:15 UTC
A commit references this bug:

Author: dim
Date: Sat Mar 25 12:29:15 UTC 2017
New revision: 315943
URL: https://svnweb.freebsd.org/changeset/base/315943

Log:
  MFC r315745:

  Cherry-pick libcxxrt commit 8a853717e61d5d55cbdf74d9d0a7545da5d5ff92:

  Author: David Chisnall <theraven@FreeBSD.org>
  Date:   Wed Mar 22 12:27:08 2017 +0000

      Simplify some code.

      realloc() with a null pointer is equivalent to malloc, so we don't need
      to handle the two cases independently.

      Fixes #46

  This should help with lang/beignet and other programs, which expect
  __cxa_demangle(name, NULL, NULL, &status) to return zero in status.

  PR:		213732

Changes:
_U  stable/10/
  stable/10/contrib/libcxxrt/typeinfo.cc
_U  stable/11/
  stable/11/contrib/libcxxrt/typeinfo.cc
_U  stable/9/
_U  stable/9/contrib/
_U  stable/9/contrib/libcxxrt/
  stable/9/contrib/libcxxrt/typeinfo.cc