#845032 valgrind: unusable on amd64: false-positive Illegal opcode at address ..

Package:
valgrind
Source:
valgrind
Description:
instrumentation framework for building dynamic analysis tools
Submitter:
Roman Lebedev
Date:
2017-12-13 14:33:03 UTC
Severity:
important
#845032#5
Date:
2016-11-19 17:29:19 UTC
From:
To:
$ valgrind --tool=massif /opt/darktable/bin/darktable
==7458== Massif, a heap profiler
==7458== Copyright (C) 2003-2015, and GNU GPL'd, by Nicholas Nethercote
==7458== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright
info
==7458== Command: /opt/darktable/bin/darktable
==7458==
vex amd64->IR: unhandled instruction bytes: 0x8F 0xEA 0x78 0x10 0xD0 0x4
0x1 0x0 0x0 0xE9
vex amd64->IR:   REX=0 REX.W=0 REX.R=0 REX.X=0 REX.B=0
vex amd64->IR:   VEX=0 VEX.L=0 VEX.nVVVV=0x0 ESC=NONE
vex amd64->IR:   PFX.66=0 PFX.F2=0 PFX.F3=0
==7458== valgrind: Unrecognised instruction at address 0x4eb5f8f.
==7458==    at 0x4EB5F8F: dt_init (darktable.c:315)
==7458==    by 0x108BAF: main (main.c:24)
==7458== Your program just tried to execute an instruction that Valgrind
==7458== did not recognise.  There are two possible reasons for this.
==7458== 1. Your program has a bug and erroneously jumped to a non-code
==7458==    location.  If you are running Memcheck and you just saw a
==7458==    warning about a bad jump, it's probably your program's
fault.
==7458== 2. The instruction is legitimate but Valgrind doesn't handle
it,
==7458==    i.e. it's Valgrind's fault.  If you think this is the case
or
==7458==    you are not sure, please let us know and we'll try to fix
it.
==7458== Either way, Valgrind will now raise a SIGILL signal which will
==7458== probably kill your program.
==7458==
==7458== Process terminating with default action of signal 4 (SIGILL)
==7458==  Illegal opcode at address 0x4EB5F8F
==7458==    at 0x4EB5F8F: dt_init (darktable.c:315)
==7458==    by 0x108BAF: main (main.c:24)
==7458==
Illegal instruction


If i run /opt/darktable/bin/darktable directly, it works flawlessly.
It is in /opt because it is a self-compiled version, current git master.

- -- System Information:
Debian Release: stretch/sid
  APT prefers unstable
  APT policy: (990, 'unstable'), (500, 'unstable-debug'), (1, 'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.8.0-1-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages valgrind depends on:
ii  libc6      2.24-5
ii  libc6-dbg  2.24-5

Versions of packages valgrind recommends:
ii  gdb           7.11.1-2+b1
pn  valgrind-dbg  <none>

Versions of packages valgrind suggests:
pn  alleyoop      <none>
ii  kcachegrind   4:16.08.0-1
pn  valgrind-mpi  <none>
ii  valkyrie      2.0.0-1

- -- no debconf information
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEjkF6151RK40WXe2HCDw+u0oWieAFAlgwi+kACgkQCDw+u0oW
ieBWVg/+PXUs+kSIYYbUDGIiYZ+M/tHvFkoQIg83tRBoOkT6tQKz3mc78IoaUbXN
gyAQWif4ExnyDAu5yHphG+zxryJPMF7sI7YDrFhoJddVwJ/C3b9O7kCX8v3oXmVp
Nq0mwQjEIisVcbf/QdrdJq8AmmiHYxh557fTCiEYT4Kv55rTyCSVuLtO3atl5Pt5
cfvGRZi0x09pLtaPst+hbFn0os2l9tzcyiN7iVhMTl3CnHT9ZS0E+Egj/W3/T0Ti
5vreb9gJJcLhx45knm+h4cyJ8OI32pZ4Iicuzr24hhdkUkJW6gA/huZfMlIW4w3b
1qPeN8wJzCgnRJe3/VSHCh18xUNSPC4odH7RC7o8vkVAoHeHjW1zZBvialOoxaQ5
EsJNe12wPDY8QTelNHQUASkHm1X+zSLtFOrTblEu199RhUhlU9Ck09KwJFFAn3nB
aVTbLDEhy/wUWl8yv7gRcO45h0ONFRaeniTjybP7Qv/jV7mIKOGnVuuoOHsP2Vqc
skej4ftg5g5Vg3pl92JMyJ5a2bqUSz9EZQX9CsH6o8haJEqoRoERjRKgsYkUSl66
AzKCglFSwxxgJx8V4gxbt5kIm12ua5kyf2GXi3CluFicyFVMO9qDlSOktDw5teRK
nObhx+/EPEtDoJVmuGVCuh/9swUBVT/k3isMbxlDKOsPKQDKof4=
=QacG
-----END PGP SIGNATURE-----

#845032#10
Date:
2017-12-13 14:28:39 UTC
From:
To:
Hi,

Trying the packaged version of darktable in unstable with the packaged
version of valgrind (3.13.0-1) was not able to reproduce the error.

However, I have seen a similar error with another program compiled with
the usual Debian flags.

With a self compiled version you probably have enabled some instruction
set that valgrind does not (yet) support. You might consider disabling
some instruction sets (like xop etc.).

The attached patch makes it possible for me to run the program that
failed, and it also helps me on Gentoo, where I compile with 
"-march=native -fno-xop" on an AMD FX 6300 processor.

If I enable "xop" other instructions are generated that are not
supported by valgrind.

Best,
Gert