many new regressions in ImageMagick-6.9.3 test suite when built against OpenMP 3.8 and trunk

It would be nice if the openmp developers could take a stab at
building ImageMagick-6.9.3 with openmp support enabled using clang 3.8
or trunk as we have accumulated a lot of new regressions in the
ImageMagick-6.9.3 test suite (due to segfaults in the resulting
binaries) since the hinted lock changes where committed.

https://llvm.org/bugs/show_bug.cgi?id=26184

Looking at one of these recent regressions in lldb shows...

# ./appendImages
(lldb) target create
"/sw/src/fink.build/libmagickcore6.9.q16.2-shlibs-6.9.3.0-2/ImageMagick-6.9.3-0/Magick++/tests/.libs/appendImages"
Current executable set to
'/sw/src/fink.build/libmagickcore6.9.q16.2-shlibs-6.9.3.0-2/ImageMagick-6.9.3-0/Magick++/tests/.libs/appendImages'
(x86_64).
(lldb) r
Process 63612 launched:
'/sw/src/fink.build/libmagickcore6.9.q16.2-shlibs-6.9.3.0-2/ImageMagick-6.9.3-0/Magick++/tests/.libs/appendImages'
(x86_64)
Process 63612 stopped
* thread #1: tid = 0xb4d6ce, 0x0000000100b58251
libomp.dylib`__kmp_allocate_indirect_lock + 113, queue =
'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1,
address=0x0)
    frame #0: 0x0000000100b58251 libomp.dylib`__kmp_allocate_indirect_lock + 113
libomp.dylib`__kmp_allocate_indirect_lock:
-> 0x100b58251 <+113>: movq (%rcx), %rcx
    0x100b58254 <+116>: movq %rcx, (%rax,%r13,8)
    0x100b58258 <+120>: jmp 0x100b58353 ; <+371>
    0x100b5825d <+125>: movq %r14, -0x30(%rbp)
(lldb) bt
* thread #1: tid = 0xb4d6ce, 0x0000000100b58251
libomp.dylib`__kmp_allocate_indirect_lock + 113, queue =
'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1,
address=0x0)
  * frame #0: 0x0000000100b58251 libomp.dylib`__kmp_allocate_indirect_lock + 113
    frame #1: 0x0000000100b57ec2
libomp.dylib`__kmp_init_indirect_lock(unsigned int*,
kmp_dyna_lockseq_t) + 178
    frame #2: 0x0000000100b1ae90 libomp.dylib`__kmpc_init_lock + 208
    frame #3: 0x0000000100392efa
libMagickCore-6.Q16HDRI.2.dylib`AllocateSemaphoreInfo + 74 at
semaphore.c:208
    frame #4: 0x0000000100302dd1
libMagickCore-6.Q16HDRI.2.dylib`NewLinkedList(capacity=0) + 97 at
hashmap.c:1377
    frame #5: 0x00000001002de7e9
libMagickCore-6.Q16HDRI.2.dylib`AcquireExceptionInfo [inlined]
InitializeExceptionInfo(exception=0x00000001040012a0) + 26 at
exception.c:676
    frame #6: 0x00000001002de7cf
libMagickCore-6.Q16HDRI.2.dylib`AcquireExceptionInfo + 31 at
exception.c:109
    frame #7: 0x000000010031ce63
libMagickCore-6.Q16HDRI.2.dylib`IsEventLogging + 35 at log.c:695
    frame #8: 0x000000010038232f
libMagickCore-6.Q16HDRI.2.dylib`RegistryComponentTerminus + 47 at
registry.c:327
    frame #9: 0x00000001003225d1
libMagickCore-6.Q16HDRI.2.dylib`MagickCoreTerminus + 65 at
magick.c:1375
    frame #10: 0x00007fff8b00646b libsystem_c.dylib`__cxa_finalize_ranges + 345
    frame #11: 0x00007fff8b00676f libsystem_c.dylib`exit + 55
    frame #12: 0x00007fff9ef1c5b4 libdyld.dylib`start + 8
    frame #13: 0x00007fff9ef1c5ad libdyld.dylib`start + 1
(lldb) register read
General Purpose Registers:
       rax = 0x0000000100b73170 libomp.dylib`__kmp_indirect_lock_pool
       rbx = 0x0000000100b70480 libomp.dylib`__kmp_global_lock
       rcx = 0x0000000000000000
       rdx = 0x0000000000000001
       rdi = 0x0000000104001340
       rsi = 0x0000000000000000
       rbp = 0x00007fff5fbff870
       rsp = 0x00007fff5fbff830
        r8 = 0x0000000000000001
        r9 = 0x0000000000000004
       r10 = 0x0000000005051838
       r11 = 0x0000000104000000
       r12 = 0x00000001030003e0
       r13 = 0x0000000000000001
       r14 = 0x0000000104001340
       r15 = 0x0000000000000001
       rip = 0x0000000100b58251 libomp.dylib`__kmp_allocate_indirect_lock + 113
    rflags = 0x0000000000010202
        cs = 0x000000000000002b
        fs = 0x0000000000000000
        gs = 0x0000000000000000

I would also add that ImageMagick-6.9.x has always been a regression
magnet for openmp (as clang's openmp support has never been able to
produce builds of that package which completely pass their test
suite).

Yes, we are on the case.

-- Jim

James Cownie <james.h.cownie@intel.com>
SSG/DPD/TCAR (Technical Computing, Analyzers and Runtimes)
Tel: +44 117 9071438

Just to clarify, on x86_64-apple-darwin15, the configure script for
ImageMagick-6.9.3 has to be modified with...

perl -pi -e 's|-lgomp|-L/swp/opt/llvm-3.8/lib -lomp|g' configure

so that passing ---enable-openmp to configure causes the build to use
the correct OpenMP library.