Page 1 of 1

AddOpenCLEvent in magick/cache.c causes Emacs to crash

Posted: 2018-10-17T02:09:12-07:00
by fommil
When I try to open any image in GNU Emacs, the process crashes. I ran under gdb and discovered that it is a problem with libmagick. This is the line that causes the crash

Code: Select all

emacs: magick/cache.c:306: AddOpenCLEvent: Assertion `cache_info->opencl != (OpenCLCacheInfo *) NULL' failed.
A full backtrace and my clinfo is at the bottom of this message. I'm using the mesa opencl implementation for my graphics card which is only partially supported.

A workaround is to disable OpenCL

Code: Select all

export MAGICK_OCL_DEVICE=OFF
Versions:

Code: Select all

~ emacs --version
GNU Emacs 26.1

~ pacman -Qi libmagick6 
Name            : libmagick6
Version         : 6.9.10.12-1

~ ldd /usr/bin/emacs | grep -i magic
	libMagickWand-6.Q16HDRI.so.6 => /usr/lib/libMagickWand-6.Q16HDRI.so.6 (0x00007efcb91af000)
	libMagickCore-6.Q16HDRI.so.6 => /usr/lib/libMagickCore-6.Q16HDRI.so.6 (0x00007efcb8eb9000)

Code: Select all

(gdb) run
Starting program: /usr/bin/emacs 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7fffed4df700 (LWP 9141)]
[New Thread 0x7fffe7f46700 (LWP 9142)]
[New Thread 0x7fffe7745700 (LWP 9143)]
[New Thread 0x7fffe5dcb700 (LWP 9144)]
[Detaching after vfork from child process 9145]
[Detaching after vfork from child process 9146]
[Detaching after vfork from child process 9147]
[Detaching after vfork from child process 9148]
[Detaching after vfork from child process 9149]
[Detaching after vfork from child process 9152]
[Detaching after vfork from child process 9153]
[New Thread 0x7fffc1f3e700 (LWP 9155)]
[New Thread 0x7fffc15fc700 (LWP 9156)]
[New Thread 0x7fffc0dfb700 (LWP 9157)]
[New Thread 0x7fffb3fff700 (LWP 9158)]
[New Thread 0x7fffab7fe700 (LWP 9159)]
[New Thread 0x7fffb37fe700 (LWP 9160)]
[New Thread 0x7fffb2ffd700 (LWP 9161)]
[New Thread 0x7fffb27fc700 (LWP 9162)]
[New Thread 0x7fffb1ffb700 (LWP 9163)]
[New Thread 0x7fffb17fa700 (LWP 9164)]
[New Thread 0x7fffb0ff9700 (LWP 9165)]
[New Thread 0x7fffabfff700 (LWP 9166)]
[New Thread 0x7fffaaffd700 (LWP 9167)]
[New Thread 0x7fffaa7fc700 (LWP 9168)]
[New Thread 0x7fffa9ffb700 (LWP 9169)]
[New Thread 0x7fffa97fa700 (LWP 9170)]
[New Thread 0x7fffa8ff9700 (LWP 9171)]
[New Thread 0x7fff7bfff700 (LWP 9172)]
[New Thread 0x7fff7b7fe700 (LWP 9173)]
[New Thread 0x7fff7affd700 (LWP 9174)]
[Thread 0x7fffa8ff9700 (LWP 9171) exited]
[Thread 0x7fff7affd700 (LWP 9174) exited]
[Thread 0x7fff7b7fe700 (LWP 9173) exited]
[Thread 0x7fff7bfff700 (LWP 9172) exited]
[Thread 0x7fffa97fa700 (LWP 9170) exited]
[Thread 0x7fffa9ffb700 (LWP 9169) exited]
[Thread 0x7fffaa7fc700 (LWP 9168) exited]
[Thread 0x7fffaaffd700 (LWP 9167) exited]
Error: 4 unsupported relocations
emacs: magick/cache.c:306: AddOpenCLEvent: Assertion `cache_info->opencl != (OpenCLCacheInfo *) NULL' failed.

Thread 1 "emacs" received signal SIGABRT, Aborted.
0x00007ffff3fe8d7f in raise () from /usr/lib/libc.so.6
(gdb) bt full
#0  0x00007ffff3fe8d7f in raise () at /usr/lib/libc.so.6
#1  0x00007ffff3fd3672 in abort () at /usr/lib/libc.so.6
#2  0x00007ffff3fd3548 in _nl_load_domain.cold.0 () at /usr/lib/libc.so.6
#3  0x00007ffff3fe1396 in  () at /usr/lib/libc.so.6
#4  0x00007ffff56381ff in  () at /usr/lib/libMagickCore-6.Q16HDRI.so.6
#5  0x00007ffff5613027 in  () at /usr/lib/libMagickCore-6.Q16HDRI.so.6
#6  0x00007ffff56b930c in BlurImageChannel () at /usr/lib/libMagickCore-6.Q16HDRI.so.6
#7  0x00007ffff572668e in  () at /usr/lib/libMagickCore-6.Q16HDRI.so.6
#8  0x00007ffff5726d4a in  () at /usr/lib/libMagickCore-6.Q16HDRI.so.6
#9  0x00007ffff5727aac in InitOpenCLEnv () at /usr/lib/libMagickCore-6.Q16HDRI.so.6
#10 0x00007ffff56122ea in  () at /usr/lib/libMagickCore-6.Q16HDRI.so.6
#11 0x00007ffff5615c25 in  () at /usr/lib/libMagickCore-6.Q16HDRI.so.6
#12 0x00007ffff565fc5c in CompositeImageChannel () at /usr/lib/libMagickCore-6.Q16HDRI.so.6
#13 0x00007ffff5709977 in MergeImageLayers () at /usr/lib/libMagickCore-6.Q16HDRI.so.6
#14 0x00007ffff596548b in MagickMergeImageLayers () at /usr/lib/libMagickWand-6.Q16HDRI.so.6
#15 0x00000000005e9839 in  ()
#16 0x00000000005f1b72 in  ()
#17 0x00000000005f2071 in  ()
#18 0x000000000056cced in  ()
#19 0x00000000005a8fe1 in  ()
#20 0x000000000056cc6b in  ()
#21 0x00000000005a8fe1 in  ()
#22 0x000000000056cc6b in  ()
#23 0x00000000005a8fe1 in  ()
#24 0x000000000056cc6b in  ()
#25 0x00000000005a8fe1 in  ()
#26 0x000000000056cc6b in  ()
#27 0x00000000005a8fe1 in  ()
#28 0x000000000056cc6b in  ()
#29 0x00000000005a8fe1 in  ()
#30 0x000000000056cc6b in  ()
#31 0x00000000005a8fe1 in  ()
#32 0x000000000056cc6b in  ()
#33 0x00000000005a8fe1 in  ()
#34 0x000000000056cc6b in  ()
#35 0x00000000005a8fe1 in  ()
#36 0x000000000056cc6b in  ()
#37 0x00000000005a8fe1 in  ()
#38 0x000000000056cc6b in  ()
#39 0x00000000005a8fe1 in  ()
#40 0x000000000056cc6b in  ()
#41 0x00000000005a8fe1 in  ()
#42 0x000000000056cc6b in  ()
#43 0x00000000005695ef in  ()
--Type <RET> for more, q to quit, c to continue without paging--
#44 0x000000000056cced in  ()
#45 0x000000000056ea3c in  ()
#46 0x0000000000569b5b in  ()
#47 0x000000000056cced in  ()
#48 0x00000000005a8fe1 in  ()
#49 0x000000000056cc6b in  ()
#50 0x000000000056cdaa in  ()
#51 0x0000000000504084 in  ()
#52 0x000000000056be2f in  ()
#53 0x00000000004f4e55 in  ()
#54 0x000000000056bd9e in  ()
#55 0x00000000004f4ded in  ()
#56 0x00000000004f9fe8 in  ()
#57 0x00000000004fa328 in  ()
#58 0x00000000004157eb in  ()
#59 0x00007ffff3fd5223 in __libc_start_main () at /usr/lib/libc.so.6
#60 0x000000000041658a in  ()
(gdb) quit
A debugging session is active.

Code: Select all

~ clinfo 
Number of platforms                               1
  Platform Name                                   Clover
  Platform Vendor                                 Mesa
  Platform Version                                OpenCL 1.1 Mesa 18.2.2
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_icd
  Platform Extensions function suffix             MESA

  Platform Name                                   Clover
Number of devices                                 1
  Device Name                                     Radeon RX 580 Series (POLARIS10, DRM 3.26.0, 4.18.14-arch1-1-ARCH, LLVM 7.0.0)
  Device Vendor                                   AMD
  Device Vendor ID                                0x1002
  Device Version                                  OpenCL 1.1 Mesa 18.2.2
  Driver Version                                  18.2.2
  Device OpenCL C Version                         OpenCL C 1.1 
  Device Type                                     GPU
  Device Profile                                  FULL_PROFILE
  Device Available                                Yes
  Compiler Available                              Yes
  Max compute units                               36
  Max clock frequency                             1411MHz
  Max work item dimensions                        3
  Max work item sizes                             256x256x256
  Max work group size                             256
  Preferred work group size multiple              64
  Preferred / native vector sizes                 
    char                                                16 / 16      
    short                                                8 / 8       
    int                                                  4 / 4       
    long                                                 2 / 2       
    half                                                 8 / 8        (cl_khr_fp16)
    float                                                4 / 4       
    double                                               2 / 2        (cl_khr_fp64)
  Half-precision Floating-point support           (cl_khr_fp16)
    Denormals                                     No
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 No
    Round to infinity                             No
    IEEE754-2008 fused multiply-add               No
    Support is emulated in software               No
  Single-precision Floating-point support         (core)
    Denormals                                     No
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 No
    Round to infinity                             No
    IEEE754-2008 fused multiply-add               No
    Support is emulated in software               No
    Correctly-rounded divide and sqrt operations  No
  Double-precision Floating-point support         (cl_khr_fp64)
    Denormals                                     Yes
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 Yes
    Round to infinity                             Yes
    IEEE754-2008 fused multiply-add               Yes
    Support is emulated in software               No
  Address bits                                    64, Little-Endian
  Global memory size                              4294967296 (4GiB)
  Error Correction support                        No
  Max memory allocation                           3219041280 (2.998GiB)
  Unified memory for Host and Device              No
  Minimum alignment for any data type             128 bytes
  Alignment of base address                       32768 bits (4096 bytes)
  Global Memory cache type                        None
  Image support                                   No
  Local memory type                               Local
  Local memory size                               32768 (32KiB)
  Max number of constant args                     16
  Max constant buffer size                        2147483647 (2GiB)
  Max size of kernel argument                     1024
  Queue properties                                
    Out-of-order execution                        No
    Profiling                                     Yes
  Profiling timer resolution                      0ns
  Execution capabilities                          
    Run OpenCL kernels                            Yes
    Run native kernels                            No
  Device Extensions                               cl_khr_byte_addressable_store 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_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_fp64 cl_khr_fp16

NULL platform behavior
  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  Clover
  clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)   Success [MESA]
  clCreateContext(NULL, ...) [default]            Success [MESA]
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  Success (1)
    Platform Name                                 Clover
    Device Name                                   Radeon RX 580 Series (POLARIS10, DRM 3.26.0, 4.18.14-arch1-1-ARCH, LLVM 7.0.0)
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  Success (1)
    Platform Name                                 Clover
    Device Name                                   Radeon RX 580 Series (POLARIS10, DRM 3.26.0, 4.18.14-arch1-1-ARCH, LLVM 7.0.0)
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  Success (1)
    Platform Name                                 Clover
    Device Name                                   Radeon RX 580 Series (POLARIS10, DRM 3.26.0, 4.18.14-arch1-1-ARCH, LLVM 7.0.0)

ICD loader properties
  ICD loader Name                                 OpenCL ICD Loader
  ICD loader Vendor                               OCL Icd free software
  ICD loader Version                              2.2.12
  ICD loader Profile                              OpenCL 2.2