Skip to content

fix(runner): stop leaking two descriptors per path argument - #1462

Merged
Chemaclass merged 1 commit into
mainfrom
fix/1461-make-test-targets-are-killed-exit-137-on-macos
Nov 7, 2026
Merged

Chemaclass merged 1 commit into
mainfrom
fix/1461-make-test-targets-are-killed-exit-137-on-macos

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

Summary

Closes #1461.

make test, make test/parallel and make test/strict died on macOS with exit 137 (or 134) before any test ran. The macOS crash report shows Apple's /bin/bash 3.2 aborting in realloc with "pointer being freed was not allocated". Bash 5.3 ran the same command fine.

The cause was the loop in cmd_test that reads each path argument. It used two process substitutions per argument (< <(parse_file_path_filter ...) and < <(find_files_recursive ...)). Bash 3.x keeps those descriptors open until the function returns, so passing files by name leaked two per file. The Makefile passes about 241 paths, and Bash 3.2 corrupted its heap at about 126 of them, close to 256 open descriptors. Running against the tests folder passes one argument, which is why ./bashunit tests worked.

Changes

  • parse_file_path_filter sets _BASHUNIT_HELPER_PARSED_PATH_OUT and _BASHUNIT_HELPER_PARSED_FILTER_OUT instead of printing two lines. One fewer subprocess per argument.
  • cmd_test and cmd_bench capture find_files_recursive once per argument and read the result from a here-string. || true keeps the old behavior of ignoring find's exit status, so a glob matching nothing still reports "No tests found".

Test plan

  • New acceptance test passes 120 files by name under a 120-descriptor limit. It failed before the fix with cannot duplicate fd: Too many open files.
  • make test, make test/parallel, make test/strict on macOS with /bin/bash 3.2: 2835 passed, no crash
  • make sa, make lint

cmd_test read each path argument through two process substitutions. Bash 3.x
keeps their descriptors until the function returns, so a run given many files
by name leaked two per file. Apple's Bash 3.2 corrupts its heap near 256 of
them, which killed make test, make test/parallel and make test/strict on macOS.

parse_file_path_filter now returns through slots, and the file lists for test
and bench are captured once per argument and read from a here-string.

Closes #1461
@Chemaclass
Chemaclass merged commit 2a8dbb2 into main Nov 7, 2026
39 checks passed
@Chemaclass
Chemaclass deleted the fix/1461-make-test-targets-are-killed-exit-137-on-macos branch November 7, 2026 18:22
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.

make test targets are killed (exit 137) on macOS when given the full file list

1 participant