Bug 440180 - s390x: Failed assertion in disassembler
Summary: s390x: Failed assertion in disassembler
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: vex (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-23 09:05 UTC by Florian Krohm
Modified: 2024-10-01 11:12 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Krohm 2021-07-23 09:05:40 UTC
In function construct_mnemonic this assertion fails:

   vassert(vex_strlen(prefix) + vex_strlen(suffix) +
           sizeof mask_id[0] <= sizeof buf);

The problem is that S390_MAX_MNEMONIC_LEN is too small.
It should be 9 instead of 8.
The largest opcode mnemonic without extension is 7 for ALGHSIK.
The largest opcode mnemonic with extension is 6 for STOCFH +
max. 3 letter extension makes a max length of 9.

To reproduce run this progeam

#include <stdlib.h>

int main()
{
  int *p = malloc(10);
  int ix;

// stocfhnle
  asm(".short 0xEB03");
  asm(".long  0x222222E1");
  return p[ix];
}

like so:

valgrind --trace-notbelow=1 --trace-flags=11111111 ./a.out

Here's the patch

diff --git a/VEX/priv/s390_defs.h b/VEX/priv/s390_defs.h
index 80d7336..fa6e85c 100644
--- a/VEX/priv/s390_defs.h
+++ b/VEX/priv/s390_defs.h
@@ -166,8 +166,8 @@ typedef enum
 #define S390_PPNO_MAX_SIZE_SHA512_GEN  64


-/* The length of the longest mnemonic: locgrnhe */
-#define S390_MAX_MNEMONIC_LEN  8
+/* The length of the longest mnemonic: stocfhnle */
+#define S390_MAX_MNEMONIC_LEN  9


 /*---------------------------------------------------------------*/
Comment 1 Andreas Arnez 2024-10-01 11:12:20 UTC
This Bug was fixed in the meantime with commit 67a2bb759a7c9c76fd6aa142bdb6fe342a5998e2 (s390x: Fix disassembly of locfh/locfhr, update S390_MAX_MNEMONIC_LEN).