Skip to content

[Wine] SIGILL/SIGSEGV when running game with SMC (Self-Modifying Code) patch #4299

Description

@as14725836

Description

I'm running a Windows game through Wine + Box64 on ARM64 Android (Termux). The original game works fine, but after applying a Chinese translation patch (which uses SMC/self-modifying code), Box64 crashes with SIGILL/SIGSEGV.

The error occurs immediately when the patched EXE starts. The original unpatched EXE runs without issues.

Environment

  • CPU: Cortex-A510, 8 cores
  • OS: Android 15
  • Box64 Version: 0.4.5 (dc57589)
  • Build Date: Aug 26 2026 09:25:48
  • Wine Version: wine-10.0-3proton-vanilla-wow64
  • Termux: Latest from F-Droid/GitHub

Box64 Environment

BOX64_DYNAREC=1
BOX64_DYNAREC_BIGBLOCK=0
BOX64_DYNAREC_DIRTY=1
BOX64_DYNAREC_NOHOTPAGE=1
BOX64_DYNAREC_FASTNAN=1
BOX64_DYNAREC_FORWARD=1024
BOX64_DYNAREC_MISSING=1
BOX64_DYNAREC_NATIVEFLAGS=1
BOX64_DYNAREC_WEAKBARRIER=1
BOX64_DYNAREC_CALLRET=0
BOX64_LOG=1
BOX64_SHOWSEGV=1

Error Log

Marked db 0x75cc0e94f0 as dirty, and address 0x7b2089 as creating internal SMC
29783|Emit Signal 11 at IP=0x7b20b9(??? / ?) / addr=0x7b20b9, code=0xbad0
ES=0x002b CS=0x0023 SS=0x002b DS=0x002b FS=0x004b GS=0x0000 FSBASE=0x7ffc2000 GSBASE=0x7ffc0000
RAX=00000001 RCX=00000000 RDX=00869000 RBX=7ffd1000 flags=???????
RSP=0020ff3c RBP=0020ff58 RSI=00000000 RDI=00000000 EIP=007b20b9 Emu Stack: 0x75cc4a0000 0x800000
Signal 11: si_addr=(nil), TRAPNO=13, ERR=0, RIP=0x7b20b9, prot=87, mmapped:3
Context has been changed in Sigactionhanlder, doing siglongjmp to resume emu at 0x4ffff2f82c, RSP=0x20f800 (resume with Dynarec)
... (repeated) ...
0x6fc000: Dynarec stopped because of x86 Opcode 0F 3F 07 0B 64 8F 05 00 00 00 00 83 C4 04 83
29783|Emit Signal 4 at IP=0x6fc000(??? / ?) / addr=0x6fc000, code=0x0
SIGILL: Opcode at ip is 0f 3f 07 0b 64 8f
Signal 4: si_addr=0x6fc000, TRAPNO=6, ERR=0, RIP=0x6fc000, prot=87, mmapped:3


### Key Observations
1. **Original game**: Works fine
2. **Patched game**: Crashes immediately
3. **Error type**: SIGILL (Illegal instruction) at address 0x6fc000
4. **Offending opcode**: `0F 3F 07 0B 64 8F` (unrecognized by Dynarec)
5. **SMC detected**: "Marked db ... as dirty, and address ... as creating internal SMC"
6. **Workaround**: Running with `BOX64_DYNAREC=0` (interpreter mode) works but is slow

### What I've Tried
- Adjusting `BOX64_DYNAREC_BIGBLOCK=0`
- Adjusting `BOX64_DYNAREC_FORWARD=0`
- Adjusting `BOX64_DYNAREC_CALLRET=0`
- Setting `BOX64_DYNAREC_WEAKBARRIER=1`
- All resulted in the same crash

### Expected Behavior
The translated/patched game should run similarly to the original game.

### Additional Context
- The translation patch modifies the game's code at runtime (SMC)
- This is common for Chinese translation patches for visual novels
- The game is a visual novel (RPG Maker/KiriKiri engine)

### Request
Could the Dynarec be improved to handle SMC better, or could the `0F 3F` opcode be added to the emulation?

Thank you for your work on Box64!

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions