Skip to content

Fixes for malloc-related bugs - #228

Open
nchaimov wants to merge 3 commits into
llnl:develfrom
ParaToolsInc:app-malloc-fixes
Open

nchaimov wants to merge 3 commits into
llnl:develfrom
ParaToolsInc:app-malloc-fixes

Conversation

@nchaimov

@nchaimov nchaimov commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

This PR fixes three issues found in testing with the E4S testsuite, all related to Spindle's use of the application's malloc:

  • jemalloc's malloc hangs under Spindle #225: The jemalloc implementation of malloc calls readlink inside of the first malloc in order to read a configuration file. The readlink was then intercepted by Spindle, which was then itself trying to malloc while initializing a thread-local variable. This is fixed by changing the TLS model to initial-exec.
  • App linked against jemalloc crashes freeing result of realpath #226: When allocating memory which would be returned to the application (here, in realpath), the memory would be allocated with the malloc from libc even if the application used an alternate malloc. When the application then tried to free this memory, it would use its alternate implementation of free. This is fixed by, instead of always using libc, finding malloc by iterating over the link maps to find a DSO that exports a defined malloc symbol.
  • Crash in patch_on_linkactivity when l_name not long enough for last_orig_name #227: When linking against libraries, Spack can generate long paths padded with many prefixed slashes. patch_on_linkactivity attempts to patch l_name back to the original path rather than Spindle's relocated path. If the original path is longer than Spindle's relocated path, it must allocate memory in which to store the original path, which it does with the application's malloc. However, this could occur early, before LA_ACT_CONSISTENT, in which case it would be unsafe to use the obtained malloc. This is fixed by checking whether LA_ACT_CONSISTENT has already been seen, and falling back to not replacing l_name with the original path if it hasn't and Spindle can't safely use the application's malloc yet.

New tests check for interoperability with alternate malloc implementations. tagmalloc.c wraps libc malloc, attaching a tag to allocated memory so that we can verify on free that it came from this wrapper. realpath_free_test and realpath_free_lib_test include the wrapper directly in the executable or link against it as a shared library, respectively, and verify that Spindle's readlink returns memory allocated through the wrapper. long_needed_path_test, long_needed_app_malloc_test, and long_needed_lib_malloc_test generate an executable which links against a library via a long, slash-padded path, forcing the attempt to allocate storage for l_name, and verifies that this does not crash with libc malloc or an alternate malloc.

I have rerun the E4S testsuite on this PR. The chapel and adios2 tests, which previously failed, pass with this PR, and no new failures are introduced. After this PR, the stc test is the only remaining E4S test failure.

Closes #225. Closes #226. Closes #227.

@nchaimov
nchaimov requested a review from mplegendre October 6, 2026 00:15
@nchaimov
nchaimov deployed to Spindle CI October 6, 2026 00:16 — with GitHub Actions Active
@nchaimov
nchaimov deployed to Spindle CI October 6, 2026 00:16 — with GitHub Actions Active
@nchaimov
nchaimov deployed to Spindle CI October 6, 2026 00:16 — with GitHub Actions Active
@nchaimov
nchaimov deployed to Spindle CI October 6, 2026 00:16 — with GitHub Actions Active
@nchaimov
nchaimov deployed to Spindle CI October 6, 2026 00:16 — with GitHub Actions Active
@nchaimov
nchaimov deployed to Spindle CI October 6, 2026 00:16 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
Spindle CI — eee52342 Deployed Oct 6, 2026 by nchaimov via Testsuite (Slurm rshlaunch, Ubuntu) #274
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant