#781998 libopenblas-base: i386 binaries crash on 586 processors because they don't support SSE instructions

Package:
libopenblas-base
Source:
openblas
Description:
Optimized BLAS (linear algebra) library (transitional)
Submitter:
Christian Kastner
Date:
2015-04-28 20:27:05 UTC
Severity:
important
#781998#5
Date:
2015-04-06 10:16:39 UTC
From:
To:
Hi,

When using the libraries provided by libopenblas-base:i386 on a computer
with a Pentium (586) processor, a program may crash with SIGILL. Here is
the tail of the output of the upstream test suite:

  |  OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 ./sblat3 < ./sblat3.dat
  |  Makefile:59: recipe for target 'level3' failed
  |
  |  Program received signal SIGILL: Illegal instruction.
  |
  |  Backtrace for this error:
  |  #0  0xB76D9D6E
  |  #1  0xB76DA3C7
  |  #2  0xB77D9CDF
  |  #3  0xB67A9388
  |  Illegal instruction


This is because the libraries were built with SSE optimizations enabled.

The decision to use SSE appears to be determined at compile-time -- see
cpuid.h and cpuid_x86.c -- so the optimizations are based on whatever
the buildd supports, and not what the target supports.

However, as we still officially support 586 processors on i386, the
customary solution is to to disable SSE optimizations entirely for i386.
See [1] for some examples.

To reproduce this issue, you can use vmdebootstrap(8) and QEMU to
quickly recreate such an environment, and use the autopkgtest submitted
in #781996 [2] to run the tests against the locally installed binaries:

    $ sudo vmdebootstrap \
            --size 2g \
            --owner <YOUR-USERNAME> \
            --enable-dhcp \
            --mirror http://http.debian.net/debian \
            --configure-apt \
            --distribution sid \
            --arch i386 \
            --foreign /usr/bin/qemu-i386-static \
            --no-kernel \
            --package linux-image-586 \
            --package autopkgtest \
            --image sid.raw

    $ qemu-system-i386 -enable-kvm -cpu pentium sid.raw

Then, in the guest, execute the autopkgtest command from #781996.

Regards,
Christian


[1] http://codesearch.debian.net/results/sse2%20path%3Adebian%2Frules/page_0

[2] https://bugs.debian.org/781996

#781998#10
Date:
2015-04-28 18:37:10 UTC
From:
To:
Le lundi 06 avril 2015 à 12:16 +0200, Christian Kastner a écrit :

Thanks for your report.

However your diagnostic is slightly incorrect. On x86 archs, OpenBLAS is
compiled with the so-called "dynamic arch" feature. The library binary
contains kernels optimized for several different CPUs, and the right
kernel is selected at runtime after detecting the CPU.

So your problem comes either because the binary does not contain a
kernel suitable for 586, or because the CPU detection goes wrong.

I know that CPU detection does not always work very well in VMs (see
#743490 for an example). Did your crash occur on real 586 hardware, or
in a VM?

Cheers,

#781998#15
Date:
2015-04-28 20:22:22 UTC
From:
To:
Hi Sébastien,

Oh, I wasn't aware of this, sorry.

I don't have a real 586, but I have an real AMD Geode LX800, which is an
x86 CPU which also lacks SSE, and I managed to reproduce the issue
there. Full log attached.

This is a wheezy system, but with the openblas packages + dependencies
from jessie. The hardware is a PC Engines ALIX 2D.13 system board. I ran
the tests just as the autopkgtest would have done from #781996, but I
executed all the steps manually.

Please let me know if there is anything else I can do.

Regards,
Christian