Skip to content

armv7a: dl_impl segfaults under qemu-arm during persistent-sqlite TH #147

@jappeace-sloth

Description

@jappeace-sloth

Problem

Cross-compiling for armv7a fails with a segfault in dl_impl.c when QEMU arm tries to evaluate Template Haskell in persistent-sqlite (makeCompatibleKeyInstances).

The iserv-proxy-interpreter crashes during symbol table initialization:

dl_impl: init_symtab called
dl_impl: g_nsyms = 0x1e41e
dl_impl: g_strsz = 0x7fb433
dl_impl: g_symtab = 0x1024c
dl_impl: g_strtab = 0x2e6524
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
iserv-proxy: {handle: <socket: 18>}: GHCi.Message.remoteCall: end of file

The failing TH splice is in Database/Persist/Sqlite.hs:

Code: makeCompatibleKeyInstances
        [t| forall b. Compatible b (RawSqlite b) |]

Reproduction

From prrrrrrrrr (or any consumer with persistent-sqlite as a cross-dep):

nix-build nix/android.nix --argstr androidArch armv7a

Analysis

  • dl_impl initializes its symbol table from the static iserv-proxy-interpreter binary's ELF headers
  • g_symtab = 0x1024c looks suspiciously low — possibly a file offset being used as a memory address, or the symbol table falls in an unmapped region under QEMU arm
  • aarch64 builds work fine (CI passes), only armv7a is affected
  • armv7a intentionally omits -pie (because "ARM32 CRT startup doesn't reliably relocate .dynsym entries in static PIE") — this non-PIE setup may interact poorly with how dl_impl reads the symbol table
  • prrrrrrrrr CI never builds armv7a (apkArm7a is defined in ci.nix but not built), so this was never caught

Environment

🤖 Generated with Claude Code

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