Skip to content

fix(profiler): link BAMPerfProfiler with 16 KB max page size - #390

Open
shashankm03 wants to merge 1 commit into
bamlab:mainfrom
shashankm03:fix/profiler-16kb-page-size
Open

shashankm03 wants to merge 1 commit into
bamlab:mainfrom
shashankm03:fix/profiler-16kb-page-size

Conversation

@shashankm03

Copy link
Copy Markdown

Fixes #389

Problem

On devices that use 16 KB memory pages (Android 15+ images such as ..._ps16k), flashlight test crashes at startup: adb shell /data/local/tmp/BAMPerfProfiler printCpuClockTick exits with 139 (SIGSEGV). The prebuilt profiler binaries have 4 KB-aligned PT_LOAD segments (p_align = 0x1000), which a 16 KB-page kernel cannot map.

Change

  • CMakeLists.txt: link BAMPerfProfiler with -Wl,-z,max-page-size=16384 via target_link_options. NDK r28+ does this by default; this keeps older NDKs working too.
  • Rebuilt the four prebuilt binaries in cpp-profiler/bin/ with NDK 27.1.12297006 using the existing build_for_abi.sh, so the diff for those files is binary.

Verification

Arm64 emulator, android-37.2;google_apis_playstore_ps16k (getconf PAGE_SIZE = 16384):

Binary printCpuClockTick
v0.18.0 prebuilt exit 139
rebuilt arm64 prints 100

LOAD segment alignment of the rebuilt arm64 and x86_64 binaries is now 16 KB (was 4 KB).

Not verified

  • I only ran the rebuilt arm64 binary, and only the printCpuClockTick command, not a full flashlight test run (the CLI embeds the binaries, so that needs a CLI build).
  • armeabi-v7a, x86 and x86_64 are built with the same flag but not run.
  • I did not run yarn build, lint or the test suite.

If you would rather regenerate the binaries in your own pipeline, the CMakeLists.txt change on its own is the fix, and the binary files can be dropped from this PR.

Android 15+ devices can run with 16 KB memory pages. The shipped profiler binaries have 4 KB-aligned
LOAD segments and segfault (exit 139) on such devices, so flashlight test fails at startup.

Add -Wl,-z,max-page-size=16384 to the CMake target (NDK r28+ does this by default) and rebuild the
four prebuilt binaries with NDK 27.1.

Verified on an arm64 emulator with 16 KB pages (android-37.2 google_apis_playstore_ps16k): the old
binary exits 139 on printCpuClockTick, the rebuilt one prints the clock tick.
@netlify

netlify Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for flashlight-docs canceled.

Name Link
🔨 Latest commit a35b19d
🔍 Latest deploy log https://app.netlify.com/projects/flashlight-docs/deploys/6ace0a68b5669fc726f1fb29

This branch has not been deployed

No deployments
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.

BAMPerfProfiler segfaults on 16 KB page-size devices (Android 17 emulator)

1 participant