Skip to content

Investigate and fix macOS CI test failure (#370) - #371

Merged
jiegec merged 1 commit into
lsof-org:masterfrom
hugojosealmeida:sdlc/issue-370-investigate-and-fix-macos-ci-test-failur
Oct 29, 2026
Merged

jiegec merged 1 commit into
lsof-org:masterfrom
hugojosealmeida:sdlc/issue-370-investigate-and-fix-macos-ci-test-failur

Conversation

@hugojosealmeida

@hugojosealmeida hugojosealmeida commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When -i@host resolves to several addresses in one hostent, enter_nwad() created one nwad entry per address but stored the same arg allocation (and the same proto pointer) in all of them. lsof_destroy() frees np->arg and np->proto for every entry, so multi-address host names caused a double free. On macOS that aborted lsof before its stdio buffers were flushed, which is why LTsock reported “no client socket by host and port” in CI.

Each nwad now owns independent copies of its argument and protocol strings, and the caller-owned protocol string is released once after all address entries have been created.

Changes

  • src/arg.c: moved argument allocation into the per-address nwad construction, copy proto per entry, free partial allocations on failure, and free the caller’s n.proto once on the success path.
  • tests/case-23-multi-address-hostname.bash: regression test that runs lsof -i@<local hostname> when the host name resolves to multiple addresses and fails if lsof is terminated by a signal.
  • Makefile.am: registered the new dialect-neutral test with the autotools test suite.

Verification

  • make -j4 -> success
  • bash ./check.bash darwin -> 15/15 test cases passed, 0 failed, 0 skipped
  • bash tests/case-23-multi-address-hostname.bash against the pre-fix binary -> fails with status 133 (SIGTRAP); passes against the fixed binary
  • bash -n tests/case-23-multi-address-hostname.bash -> syntax check passed
  • git diff --check -> no whitespace errors

Risks / Follow-ups

The new test skips when python3 is unavailable or when the machine host name has fewer than two addresses in one family. This host and the macOS CI runner both resolve the host name to multiple addresses, so the regression path is exercised there.


This PR is AI Assisted.
Closes #370

@jiegec
jiegec merged commit a57fc55 into lsof-org:master Oct 29, 2026
16 of 17 checks passed
@hugojosealmeida

Copy link
Copy Markdown
Contributor Author

@jiegec Thanks. There is still a CI failure for freeBSD. see #373

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.

Investigate and fix macOS CI test failure

2 participants