You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fee8acc
Browse filesBrowse the repository at this point in the historyBrowse files
mem: the pre-fork pkg arena must not be hugetlb - a child's COW there is a SIGBUS
Every forked child inherits the attendant's pkg arena copy-on-write and
keeps it for life (module state parsed pre-fork lives there). While that
arena sat on MAP_HUGETLB, a child's first write into any of its pages
needed a fresh huge page - no 4K fallback inside a hugetlb VMA, and a
forked child holds no reservation on its parent's mapping - so with the
pool momentarily empty the fault was a silent SIGBUS. Startup exposed
it deterministically: the last no-script child (TCP main) freed the
inherited route AST before swapping to its own arena, and died with
'failed to initialize child process N / cannot fork tcp main process'
the moment the pool ran short (08-07 slot 52 on x86, again on an ARM
box with a small pool). The 08-07 ordering fix made that path free
against the right arena; it could not make it pool-independent.
Two changes, either sufficient, both kept:
- HG_INIT_INHERITED: hg_malloc_init() takes a flags word; the pre-fork
pkg arena passes it and hg_mem_reserve() starts its ladder at THP.
THP COW splits the huge PMD and copies one 4K page - it cannot SIGBUS,
and it cuts every child's COW cost from 2 MB per touched page to 4 KB.
Per-child arenas are never inherited and keep the full ladder.
- internal_fork_child_setup() no longer walks the inherited route AST
with pkg_free under HG pkg: the child abandons that arena wholesale,
so the frees bought nothing and were the one pre-swap writer.
Proven fail-first on a 16-child rig (-m 32 -M 8): pool 40 and 60 -
unpatched dies at child 14 = TCP main, strace shows SIGBUS BUS_ADRERR
with si_addr inside the attendant's 8 MB MAP_PRIVATE|MAP_HUGETLB
mapping; patched starts all 17 processes on the same pools, and more
children land on hugetlb since the pool no longer feeds the parent's
arena or COW pages. Pool 0 starts either way, as the mechanism predicts.
0 commit comments