Skip to content

Remove unreachable dead code in t07_body musl variant (issue #592) - #882

Merged
jbachorik merged 2 commits into
mainfrom
issue-592
Oct 22, 2026
Merged

jbachorik merged 2 commits into
mainfrom
issue-592

Conversation

@jbachorik

@jbachorik jbachorik commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?:
Removes the remaining instance of the unreachable dead code flagged in #592: the musl variant of t07_body in ddprof-lib/src/test/cpp/thread_teardown_safety_ut.cpp still ended with ProfiledThread::release(); return nullptr; after the while (true) { pthread_testcancel(); usleep(100); } loop — statements that can never execute, because the only exit from the loop is cancellation, which calls pthread_exit(PTHREAD_CANCELED) (musl src/thread/pthread_cancel.c::__cancel()), runs the registered cleanup handler and terminates the thread.

pthread_cleanup_pop(0) is kept: musl's pthread_cleanup_push/pop are paired macros that open/close a do { ... } while (0) block, so the pop is lexically required even though it is unreachable. The tail is now marked __builtin_unreachable(), mirroring the glibc variant.

Also updates AGENTS.md / README.md / utils/README.md to recommend colima-backed Docker (--container=docker) for container tests on macOS instead of podman: podman aborts container commands locally because its credential-helper lookup for the Datadog registries (ddtool) cannot reach vault outside the CI network. The script's default runtime is unchanged.

Motivation:
Closes #592 (sphinx review finding). The glibc half of the issue — the __pthread_unregister_cancel / sigaction restore / ProfiledThread::release() dead tail in the same function — was already removed on main; this PR completes the fix by removing the analogous musl-path dead code that survived, so the issue is fully addressed.

Additional Notes:
Reachability verified against primary sources:

  • musl: pthread_testcancel → __testcancel → __cancel() → pthread_exit(PTHREAD_CANCELED) (declared _Noreturn); __pthread_exit walks the cancelbuf chain, running the cleanup handler.
  • glibc: nptl/unwind.c:unwind_stop() longjmps to the cancel_jmp_buf registered by __pthread_register_cancel.

How to test the change?:
Behavior-preserving (test-only) change; thread_teardown_safety_ut passes before and after:

./utils/run-containers-tests.sh --container=docker --libc=musl --config=debug --gtest --gtest-task=thread_teardown_safety_ut --mount --run
./utils/run-containers-tests.sh --container=docker --libc=glibc --config=debug --gtest --gtest-task=thread_teardown_safety_ut --mount --run

Both report BUILD SUCCESSFUL; the executable's gtest output shows 14 tests ... PASSED on musl, including ForcedUnwindWithConcurrentSignalDoesNotCrash.

For Datadog employees:

  • If this PR touches code that signs or publishes builds or packages, or handles
    credentials of any kind, I've requested a security review (run the dd:platform-security-review
    skill, or file a request via the PSEC review form).
    bewaire also runs automatically on every PR.
  • This PR doesn't touch any of that.
  • JIRA: [JIRA-XXXX]

The musl t07_body only exits the cancellation loop via pthread_exit
(PTHREAD_CANCELED), which runs the registered cleanup handler and
terminates the thread, so the trailing ProfiledThread::release() and
return were unreachable. Keep pthread_cleanup_pop(0) — it is
lexically required to pair with pthread_cleanup_push — and mark the
tail __builtin_unreachable() like the glibc variant.
podman aborts container commands locally because its credential-helper
lookup for the Datadog registries (ddtool) cannot reach vault outside
the CI network. Document colima as the macOS runtime in AGENTS.md,
README.md and utils/README.md; the script default stays podman for CI.
@jbachorik jbachorik added the AI label Oct 21, 2026
@jbachorik
jbachorik marked this pull request as ready for review October 21, 2026 20:03
@jbachorik
jbachorik requested a review from a team as a code owner October 21, 2026 20:03
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T20:04:43.657345Z b412cd0 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: PASS

More details

The musl change preserves the cancellation cleanup handler and required cleanup macro pairing while removing an unreachable tail. The completed static review identified no reportable regression.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit b412cd0

@dd-octo-sts

dd-octo-sts Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

CI Test Results

Run: #39666677249 | Commit: ea30cc2 | Duration: 19m 0s (longest job)

✅ All 32 test jobs passed

Status Overview

JDK glibc-aarch64/debug glibc-amd64/debug musl-aarch64/debug musl-amd64/debug
8 - ✅ - -
8-ibm - ✅ - -
8-j9 ✅ ✅ - -
8-librca - - ✅ ✅
8-orcl - ✅ - -
11 - ✅ - -
11-j9 ✅ ✅ - -
11-librca - - ✅ ✅
17 ✅ ✅ - -
17-graal ✅ ✅ - -
17-j9 ✅ ✅ - -
17-librca - - ✅ ✅
21 ✅ ✅ - -
21-graal ✅ ✅ - -
21-librca - - ✅ ✅
25 ✅ ✅ - -
25-graal ✅ ✅ - -
25-librca - - ✅ ✅

Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled

Summary: Total: 32 | Passed: 32 | Failed: 0


Updated: 2026-10-21 20:29:00 UTC

@dd-octo-sts

dd-octo-sts Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

✅ All 40 integration tests passed

📊 Dashboard · 👷 Pipeline · 📦 b412cd09

@jbachorik
jbachorik merged commit 17c2844 into main Oct 22, 2026
201 of 208 checks passed
@jbachorik
jbachorik deleted the issue-592 branch October 22, 2026 07:23
@github-actions github-actions Bot added this to the 1.52.0 milestone Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment