#3054·capstone

Java binding broken: Considered registers not in sync with the binding code

Author: PAX523Created Aug 31, 2026Updated Aug 31, 2026
Labelsbugjava

Work environment

Questions Answers
System Capstone runs on OS/arch/bits Debian
Capstone module affected x86
Source of Capstone git clone
Version/git commit v6, (next)

Expected behavior

If you leverage the Java binding for disassembling, you successfully receive the assembly

Actual behavior

The Java binding fails at the very beginning due to an illegal array index access on the Java binding-side

Steps to reproduce the behavior

I've attached a very simple Portable Executable: example-portable-executable.zip

  • inline-strings.pe: the original Portable Executable created with Flat Assembler
  • inline-strings.hex: only the opcodes to be disassembled in hex notation
  • inline-strings.asm: the original assembly used in Flat Assembler
java
Capstone disassembler = new Capstone(Capstone.CS_ARCH_X86, Capstone.CS_MODE_32);
disassembler.disasm(bytesToDisassemble, 4198400);

See: Example.java

Additional Logs, screenshots, source code, configuration dump, ...

It's eye-catching that the C header file Capstone.h specifies this constant:

c
#define MAX_IMPL_R_REGS 20

But the corresponding Java binding Capstone.java specifies an old size from before the refactoring:

java
public short[] regs_read = new short[16];

Source: capstone-engine/capstone