Bug 499561 - Unrecognised instruction in Qt 6.8.1
Summary: Unrecognised instruction in Qt 6.8.1
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: vex (other bugs)
Version First Reported In: 3.25 GIT
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-02-05 19:28 UTC by dnovomesky
Modified: 2025-02-05 21:10 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dnovomesky 2025-02-05 19:28:43 UTC
Hello,

on Gentoo Linux on AMD Ryzen 5, valgrind sees unrecognized instruction in Qt's library when it is compiled using -march=native switch.

==19031== Memcheck, a memory error detector
==19031== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==19031== Using Valgrind-3.25.0.GIT and LibVEX; rerun with -h for copyright info
==19031== Command: bin/readtest jxl
==19031==
vex amd64->IR: unhandled instruction bytes: 0xC4 0xE2 0x7D 0xDC 0xC9 0x48 0x39 0xF2 0x73 0x4E
vex amd64->IR:   REX=0 REX.W=0 REX.R=0 REX.X=0 REX.B=0
vex amd64->IR:   VEX=1 VEX.L=1 VEX.nVVVV=0x0 ESC=0F38
vex amd64->IR:   PFX.66=1 PFX.F2=0 PFX.F3=0
==19031== valgrind: Unrecognised instruction at address 0x540375e.
==19031==    at 0x540375E: unsigned long aeshash256_ge32<(ZeroExtension)0>(long long __vector(4), long long __vector(2) const*, long long __vector(2) const*, unsigned long) (in /usr/lib64/libQt6Core.so.6.8.1)
==19031==    by 0x523379F: QCommandLineParser::addOption(QCommandLineOption const&) (in /usr/lib64/libQt6Core.so.6.8.1)
==19031==    by 0x10F335: main (readtest.cpp:216)
==19031== Your program just tried to execute an instruction that Valgrind
==19031== did not recognise.  There are two possible reasons for this.
==19031== 1. Your program has a bug and erroneously jumped to a non-code
==19031==    location.  If you are running Memcheck and you just saw a
==19031==    warning about a bad jump, it's probably your program's fault.
==19031== 2. The instruction is legitimate but Valgrind doesn't handle it,
==19031==    i.e. it's Valgrind's fault.  If you think this is the case or
==19031==    you are not sure, please let us know and we'll try to fix it.
==19031== Either way, Valgrind will now raise a SIGILL signal which will
==19031== probably kill your program.
==19031==
==19031== Process terminating with default action of signal 4 (SIGILL)
==19031==  Illegal opcode at address 0x540375E
==19031==    at 0x540375E: unsigned long aeshash256_ge32<(ZeroExtension)0>(long long __vector(4), long long __vector(2) const*, long long __vector(2) const*, unsigned long) (in /usr/lib64/libQt6Core.so.6.8.1)
==19031==    by 0x523379F: QCommandLineParser::addOption(QCommandLineOption const&) (in /usr/lib64/libQt6Core.so.6.8.1)
==19031==    by 0x10F335: main (readtest.cpp:216)
Comment 1 Paul Floyd 2025-02-05 20:35:27 UTC
Looks like that is "vaesenc ymm1,ymm0,ymm1".

From what I see we support the 128bit xmm version but not 256bit ymm.
Comment 2 Mark Wielaard 2025-02-05 21:10:05 UTC
(In reply to dnovomesky from comment #0)
> on Gentoo Linux on AMD Ryzen 5, valgrind sees unrecognized instruction in
> Qt's library when it is compiled using -march=native switch.

Note that in general -march=native won't work when run under valgrind since the "native" cpu instructions might not be supported by valgrind (as is the case here). Your program should really check the cpuid during runtime.

(In reply to Paul Floyd from comment #1)
> Looks like that is "vaesenc ymm1,ymm0,ymm1".
> 
> From what I see we support the 128bit xmm version but not 256bit ymm.

Note that the 256bit variant is only supported when the VAES CPUID bit is set (technically not part of AVX512 but normally an addition to).
See https://en.wikipedia.org/wiki/AVX-512#VAES