Skip to content

inet_gethost aborts (FORTIFY FD_SET >= FD_SETSIZE 1024) on Android x86_64 #43

Description

@GenericJam

Summary

On an Android x86_64 target, the inet_gethost helper from the bundled OTP
runtime aborts under Android's FORTIFY runtime check:

inet_gethost[<pid>]: WARNING:Unable to write to child process.
FORTIFY: FD_SET: file descriptor 28872 >= FD_SETSIZE 1024
F DEBUG : Cmdline: /data/.../files/otp/erts-17.0/bin/inet_gethost 4
F DEBUG : pid: <pid>, name: inet_gethost
F DEBUG : #03 pc ... /data/app/.../lib/x86_64/libinet_gethost.so

inet_gethost calls FD_SET(fd, ...) with an fd (28872 in this run) that
exceeds FD_SETSIZE (1024). Android's FORTIFY (_FORTIFY_SOURCE) turns the
out-of-range FD_SET into a SIGABRT.

Impact

Non-fatal — the BEAM and the app keep running (the helper is re-spawned), but
name resolution routed through inet_gethost fails/retries and the helper
crashes repeatedly. Observed during normal startup, right after the app came up
and dialed its backend.

Environment

  • ABI: x86_64 (Android 13, running under Waydroid on Linux)
  • OTP runtime: otp-android-x86_64-5c9c69fc, erts-17.0
  • libinet_gethost.so from the app's lib/x86_64/

Likely cause

inet_gethost (erts) uses select() / FD_SET on its inherited communication
fd. On Android, app processes routinely hold very high fd numbers, so the
inherited fd can exceed FD_SETSIZE (1024) and overflow fd_set. This is an
erts-level concern (inet_gethost.c) and could in principle affect any Android
ABI where the helper inherits a high fd — x86_64 just made it reproducible here.

Possible directions:

  • build/patch the bundled erts inet_gethost to use poll() instead of
    select() / FD_SET (discussed upstream in OTP), or
  • dup the helper's communication fd below FD_SETSIZE before it runs.

Repro

  1. Build + deploy a mob app for x86_64 (mix mob.deploy --native, abiFilters
    including x86_64).
  2. Launch on an x86_64 Android target (e.g. Waydroid).
  3. Watch logcat (BEAMout / inet_gethost / DEBUG) during startup — the
    FORTIFY abort fires when a hostname lookup is routed through the helper.

Observed while standing up an x86_64 Waydroid CI target. Happy to attach a full
erl_crash.dump / logcat if useful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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