Skip to content

feat(android): emit ELF GNU build-id for NDK native-crash images#1

Merged
nitinstp23 merged 3 commits into
mainfrom
feat/android-ndk-build-id
Jun 16, 2026
Merged

feat(android): emit ELF GNU build-id for NDK native-crash images#1
nitinstp23 merged 3 commits into
mainfrom
feat/android-ndk-build-id

Conversation

@nitinstp23

Copy link
Copy Markdown
Contributor

What & why

Enables backend symbolication of Android NDK (.so) native crash frames by emitting each native image's ELF GNU build-id as uuid in crash.binary_images_json — the analog of an iOS dSYM UUID (Scout RUM SPEC §5.4 multi-image symbolication). Without this, NDK images carry only {base, path} and cannot be matched to uploaded symbols.

iOS dSYM images already carry a per-image uuid (from KSCrash) and are unchanged.

How

  • ElfBuildId.kt — a minimal, pure-JVM ELF parser that reads NT_GNU_BUILD_ID from an on-disk .so (handles 32/64-bit, LE/BE; defensive bounds checks).
  • CrashReporter.getPendingCrashReports — enriches crash.binary_images_json at report-assembly time, on a normal thread (next launch), by resolving each image's basename against the app's nativeLibraryDir and reading its build-id. The async-signal-safe crash handler is untouched (it still captures only base + name).
  • Graceful degradation: images we can't resolve (system libs, or libs not extracted to disk) are left without a uuid → their frames stay raw, nothing errors.

Testing

  • ElfBuildIdTest (JUnit) reads a committed ELF .so fixture and asserts the build-id, plus missing-file / non-ELF cases. Adds the android unit-test source set + junit test dependency.
  • The parsing algorithm was additionally validated against the same fixture out-of-band (correct build-id extracted).

Notes

  • The uploaded .so debug_id must use the same GNU build-id (readelf -n) for matching — to be covered in the CI upload docs.

@nitinstp23 nitinstp23 self-assigned this Jun 15, 2026
@nitinstp23 nitinstp23 requested a review from nimisha-gj June 15, 2026 17:19
Comment thread CHANGELOG.md
Adds each native image's ELF GNU build-id as `uuid` in
`crash.binary_images_json` so the backend symbolizer can match Android NDK
(.so) crash frames to uploaded symbols — the analog of an iOS dSYM UUID
(SPEC §5.4 multi-image symbolication).

The crash signal handler stays async-signal-safe: it still captures only
each image's base address + name. The build-id is recovered at
report-assembly time on a normal thread (CrashReporter.getPendingCrashReports)
by resolving the image name against the app's nativeLibraryDir and reading
NT_GNU_BUILD_ID from the on-disk library via a new minimal ELF parser
(ElfBuildId). Images that can't be resolved — system libraries, or libs not
extracted to disk — are left without a uuid and their frames stay raw.

iOS dSYM images already carry a per-image uuid (from KSCrash) and are unchanged.

Adds a JUnit unit test (with a committed ELF .so fixture) and wires up the
android unit-test source set.
@nitinstp23 nitinstp23 force-pushed the feat/android-ndk-build-id branch from 6b564fa to 50b843a Compare June 16, 2026 05:42
@nitinstp23 nitinstp23 requested a review from nimisha-gj June 16, 2026 05:42
@nitinstp23 nitinstp23 merged commit bc097a2 into main Jun 16, 2026
1 check passed
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