Skip to content

fix: hex::type::Instruction rejecting valid syntax names and settings without options - #2924

Open
cbro33 wants to merge 1 commit into
WerWolv:masterfrom
cbro33:fix/instruction-syntax
Open

cbro33 wants to merge 1 commit into
WerWolv:masterfrom
cbro33:fix/instruction-syntax

Conversation

@cbro33

@cbro33 cbro33 commented Sep 30, 2026

Copy link
Copy Markdown

Problem description

hex::type::Instruction currently fails for most inputs on master. There are two separate problems:

  1. Since 4749cc4, every syntax other than "default" throws Invalid disassembler syntax name. The new if for "default" starts a second if/else chain, so "intel" sets the syntax, then fails the "default" check and ends up in the trailing else. This also breaks InstructionIntel, InstructionATNT, InstructionMASM and InstructionMotorola.

  2. A settings string without options, like "x86_64" or "aarch64", throws Unknown disassembler option ''. splitString("", ",") returns one empty string and stringToSettings() treats it as an option name. This includes the type string the disassembler view shows, e.g. hex::type::Instruction<"x86_64", "default", 0x00, 0x00>.

The second one only shows up when building against Capstone 6. With Capstone 5, fewer entries are compiled into the fixed size Options array, so the leftover slots are { "", 0 } and the empty option happens to match one of them. That is why it works on the Windows nightly (MSYS2 Capstone 5.0.9) but not on the Linux AppImage (bundled Capstone 6).

Repro, with 55 48 89 E5 31 C0 5D C3 as input:

import hex.type.instruction;
hex::type::Instruction<"x86_64", "intel", 0, 0> insn @ 0x00;
  • Linux nightly (4308ef2): Unknown disassembler option ''
  • Same with "x86_64;64bit": Invalid disassembler syntax name 'intel'
  • Expected: push rbp

Implementation description

  • Changed the if for "default" to else if so it is part of the same chain.
  • Skip empty entries after trimming in stringToSettings(). This also covers "x86_64;" and trailing commas.

Screenshots

Not applicable, no visual change.

Additional things

I built master (f2d432d) and this branch on Linux, once with the bundled Capstone 6 and once with system Capstone 5.0.9, and ran a set of patterns through imhex --pl format.

Before: on Capstone 6 the only working case was "default" with an explicit option. On Capstone 5 only "default" worked.

After, on both: "default", "intel", "at&t", "masm", the aliases, "x86_64", "x86_64;" and "aarch64" all disassemble correctly ("at&t" gives pushq %rbp). An invalid syntax or option name still errors like before.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant