Skip to content

host: treat unbounded range-end as Long.MAX_VALUE (ghidrasql #2/#3/#6) - #16

Merged
0xeb merged 1 commit into
mainfrom
fix/range-end-fallback
Jun 23, 2026
Merged

host: treat unbounded range-end as Long.MAX_VALUE (ghidrasql #2/#3/#6)#16
0xeb merged 1 commit into
mainfrom
fix/range-end-fallback

Conversation

@0xeb

@0xeb 0xeb commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Problem

Host-side companion to 0xeb/ghidrasql#7 — fixes the root cause of ghidrasql issues 0xeb/ghidrasql#2, #3, #6, where range-filtered tables (funcs, names, instructions, strings, xrefs, …) return 0 rows.

Root cause

Every range-list RPC handler fell back to program.getMaxAddress().getOffset() when the range-end was non-positive:

long defaultEnd = program.getMaxAddress().getOffset();
...
if (endOffset <= 0) { endOffset = defaultEnd; }

The C++ client sends UINT64_MAX for "all addresses", which decodes to a signed -1 here, so the fallback fired. For programs whose max address is in a low-offset space (EXTERNAL block, or offset-0 file sections) the window [start, tinyOffset] excluded all real code → 0 rows.

Fix

Add RuntimeSupport.resolveRangeEnd(long), which maps any non-positive end to Long.MAX_VALUE (truly unbounded, never getMaxAddress()), and route all 17 list handlers across 6 runtime classes through it (net −45 lines of duplicated boilerplate). Update cpp/examples to send INT64_MAX.

Either this or the client-side fix (0xeb/ghidrasql#7) is independently sufficient; shipping both fixes the defect at its source and unblocks clients that still send the old sentinel.

Verification

With an unpatched client (still sending UINT64_MAX) against this patched host, the helper's resolveRangeEnd(-1) → Long.MAX_VALUE path restores results on a triggering Linux ELF fixture: funcs 0→9, names 0→15, instructions 0→77, xrefs 0→50. Extension compiles clean; /bin/ls regression unchanged.

#2,#3,#6)

Range-list RPC handlers fell back to program.getMaxAddress().getOffset() when
the range-end was non-positive. The C++ client sends UINT64_MAX for 'all
addresses', which decodes to a signed -1 here, so the fallback fired; for
programs whose max address is in a low-offset space (EXTERNAL block or offset-0
file sections) the scan window collapsed and range-filtered tables returned 0
rows.

Add RuntimeSupport.resolveRangeEnd(), which maps any non-positive end to
Long.MAX_VALUE (truly unbounded), and route all 17 list handlers through it.
Update cpp/examples to use INT64_MAX.
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