Skip to content

fix: write full addresses when preparing JIT pages - #5

Closed
ignaciojuarez wants to merge 1 commit into
StikDebug:mainfrom
ignaciojuarez:fix/full-jit-page-addresses
Closed

ignaciojuarez wants to merge 1 commit into
StikDebug:mainfrom
ignaciojuarez:fix/full-jit-page-addresses

Conversation

@ignaciojuarez

Copy link
Copy Markdown

Problem

prepare_memory_region builds one M<addr>,1:69 packet per 16 KB page in makeBlessCommands, but writeHexAddress writes exactly 9 hex digits. Any address above 0xFFFFFFFFF (64 GB) loses its top digit.

Apps signed with com.apple.developer.kernel.extended-virtual-addressing can get JIT regions there. Example from an iPhone 17 Pro on iOS 26 (TXM), with a JVM asking for a 64 MB code cache:

  • debugserver allocated the region at 0x7239f1c000 (10 digits)
  • the batched writes went to 0x239f1c000… instead
  • the real region was never prepared, and the first JIT instruction faulted with EXC_BAD_ACCESS / KERN_CODESIGN_ERROR (0x32) at RX+0xbc

The same app with the region at 0x16ea58000 (9 digits) works, so the crash is intermittent and depends on where the region lands. The replies to the batched writes aren't checked, so the script still sees success.

Side effect: the 0x69 bytes are written to whatever happens to be mapped at the truncated address.

Fix

Write all 16 hex digits. The command length goes from 19 to 26 bytes, and the ,1:69# and checksum offsets move with it. gdb-remote accepts any address width.

Checked by compiling makeBlessCommands on its own: two pages at 0x7239f1c000 produce $M0000007239f1c000,1:69#d2$M0000007239f20000,1:69#a0, with valid checksums.

Possible follow-up: read and check each reply to the batched writes, so a failed write is reported instead of silently succeeding.

🤖 Generated with Claude Code

makeBlessCommands wrote 9 hex digits per page address, so a region above
0xFFFFFFFFF (64 GB) lost its top digit. Apps with extended virtual
addressing can get JIT regions there; the wrong pages were prepared and
the first JIT instruction failed with KERN_CODESIGN_ERROR.

Write all 16 digits (command length 19 -> 26).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ignaciojuarez added a commit to ignaciojuarez/cofre that referenced this pull request Nov 1, 2026
StikJIT's batched page prepare wrote 9 hex digits per address, so with
extended virtual addressing a JIT region at e.g. 0x7239f1c000 lost its top
digit: the wrong pages were prepared and the JVM's first JIT call died with
KERN_CODESIGN_ERROR. It was intermittent because it depends on where the
region lands.

- patches/stikjit/0001 writes all 16 digits (command 19 -> 26 bytes).
- scripts/stikjit-sources.sh applies StikJIT patches into .work/stikjit;
  the tunnel target builds that copy. Sent upstream: StikDebug/StikJIT#5.
- The detach test checks a high region reaches the helper intact.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CelloSerenity

Copy link
Copy Markdown
Member

This use case doesn't apply to the majority of our users, so I am closing this.

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.

2 participants