Skip to content

fix: -Wsafe-init checker hangs forever on test compilation - #16

Merged
halotukozak merged 9 commits into
mainfrom
fix-wsafe-init-hang
Aug 10, 2026
Merged

fix: -Wsafe-init checker hangs forever on test compilation#16
halotukozak merged 9 commits into
mainfrom
fix-wsafe-init-hang

Conversation

@halotukozak

@halotukozak halotukozak commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

CI's "Run tests" step has been hanging indefinitely on every branch that reaches test compilation (confirmed stuck 50+ minutes, not just slow — this is what was blocking PR #5 and would have blocked #3/#4/#6/#9/#10 too once they got past formatting).

Root-caused by thread-dumping the stuck Bloop/dotc process: the compiler thread was pinned at 100% CPU for 10+ minutes inside dotty.tools.dotc.transform.init.Semantic$$anon$1.traverse, recursing through TypeAccumulator.foldOver — the -Wsafe-init object-initialization checker walking a type graph it never finishes on. Verified it's not the other debug flags (-Xprint-inline, -Ycheck:all, etc.) — stripping those alone still hung identically; only removing -Wsafe-init fixed it. (Independently cross-checked via git bisect on the same symptom: the underlying complexity trigger is commit 7a3c644 "make RpcNames with no macros," which replaced a single macro-time computation with type-level match-type recursion in RpcNames.scala — that's what -Wsafe-init's checker chokes on whenever a trait has all three arities, fire+call+get, present at once, e.g. SampleApi.)

-Wsafe-init is a compile-time-only static check (catches unsafe access to not-yet-initialized fields); it doesn't change runtime behavior, so disabling it doesn't remove any actual guarantee the code relies on — it just stops the checker itself from blowing up on the inline-derivation-heavy code from the recent macro→inline refactor.

Also folded in three more independently-diagnosed CI-only fixes needed for tests to actually reach green after the hang is gone:

  • made/mcodec version-pin mismatch: project.scala requested made:0.2.1-SNAPSHOT while CI published the pinned commit locally as a different label (0.1.3-done-SNAPSHOT/stale SHA) — bumped both to made:0.3.0 (a61445c, the real v0.3.0 tag) and fixed MetadataDerivation's getAllAnnotations call site to that version's extension-method syntax.
  • mcodec's pinned commit predated made's getAnnotation: Option[A] -> A | Null change — repointed to halotukozak/mcodec#4 (a one-line fix already opened there) until it merges.
  • GoldenFixtureSuite reads fixtures/*.json relative to the process working directory; CI's other steps run from the outer checkout root (mrpc/made/mcodec are siblings there), so the bare scala-cli --power test mrpc left that resolving against the wrong directory. Added working-directory: mrpc to the test step.

Test plan

  • scala-cli compile . --test finishes in ~25s (down from indefinite hang / 150s timeout with zero progress).
  • Full scala-cli test . suite runs to completion. One pre-existing failure surfaced (AnnotationCaptureSuite) — unrelated to this change: that suite is a WIP scaffold with every test(...) commented out as //todo, and its class-body destructuring of done.operations throws at construction time. Not touched here.
  • CI green end to end with all four fixes together

🤖 Generated with Claude Code

halotukozak and others added 5 commits August 10, 2026 09:37
CI's "Run tests" step has been hanging indefinitely (confirmed 50+ min,
not just slow) on every branch that reaches the test-compile stage.
Thread-dumped the stuck Bloop/dotc process: the compiler thread was
pinned at 100% CPU for 10+ minutes inside
dotty.tools.dotc.transform.init.Semantic$$anon$1.traverse, recursing
through TypeAccumulator.foldOver -- the -Wsafe-init object-init checker
walking a type graph it never finishes.

Verified: with -Wsafe-init removed, `scala-cli compile . --test`
finishes in ~25s (down from a 150s timeout with no progress), and the
full test suite runs to completion. This is a compiler-side static
check, not a runtime guarantee, so removing it doesn't change what the
code actually does -- it just stops the checker from blowing up on the
inline-derivation-heavy code introduced by the recent macro-to-inline
refactor.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
GoldenFixtureSuite reads fixtures/*.json via a path relative to the
process working directory. CI's other steps run from the outer checkout
root (mrpc/made/mcodec are sibling directories there), so the bare
`scala-cli --power test mrpc` command left the fixture lookup resolving
against the wrong directory, failing 5 tests with FileNotFoundException.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ntax

Root cause of the "Run tests" failures wasn't a version mismatch (made
0.3.0's real API still has everything mrpc needs) - it was that ci.yml
pinned a made commit (16bfbdb) 37 commits behind v0.3.0, missing:
  - getAllAnnotations entirely (added in c5a98e5/d361b36)
  - containsOnly evidence for Tuple.Tail/Reverse/Concat/Zip (ad6f7a4/713d57a),
    which mrpc's recursive tuple-walking macros (RpcNames, OpPlan,
    MetadataDerivation, Plans) depend on to chain containsOnly evidence
    across `.tail` calls
  - InputElem.ExtractLabel (24800ec)

Bumping the pin to v0.3.0 (a61445c) picks up all three, purely additive
per the made-side diff (no removed/renamed members between the two).

The one real mrpc-side fix: made's getAllAnnotations is an extension
method (`self.getAllAnnotations[A]`), not a positional function
(`getAllAnnotations(self)(using ...)[A]`) - MetadataDerivation.allTerms
was calling it the old way.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
mcodec's old pinned commit predates made's getAnnotation Option[A] -> A |
Null change (same root cause as the made pin bump in the previous commit).
Repointing to the fix branch until halotukozak-com/mcodec#4 merges.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…T vs 0.1.3-done-SNAPSHOT)

project.scala requested made:0.2.1-SNAPSHOT while ci.yml published the
pinned made commit locally as 0.1.3-done-SNAPSHOT - neither resolved to
the other, so CI's "Run tests" step failed on every commit regardless of
content. Aligning both on 0.3.0 per the repo owner's direction.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…sh entirely

Both are properly released now (made v0.3.0, mcodec v0.1.0, the latter
including the made-0.3.0 compat fix from mcodec#4). No more pinned commits,
no more publishLocal dance.
@halotukozak
halotukozak merged commit c33a249 into main Aug 10, 2026
1 check passed
@halotukozak
halotukozak deleted the fix-wsafe-init-hang branch August 10, 2026 07:56
halotukozak added a commit that referenced this pull request Aug 10, 2026
…n tests

AsRawReal.scala fully-qualified mrpc.Fallback but AsRaw.scala/AsReal.scala
didn't import it at all - never caught locally because the CI test hang
(fixed in #16) meant this branch was never actually compiled end to end
until now.

Also marks the intentionally-shadowed Fallback givens in FallbackSuite/
MetadataFallbackSuite's "normal given wins" tests as @unused - their
presence-but-non-resolution is exactly what's being asserted, which
-Wunused:all -Werror otherwise flags as dead code.

Verified: full `scala-cli test .` passes (0 failed except the pre-existing,
already-documented AnnotationCaptureSuite issue from #16).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
halotukozak added a commit that referenced this pull request Aug 10, 2026
…n tests

AsRawReal.scala fully-qualified mrpc.Fallback but AsRaw.scala/AsReal.scala
didn't import it at all - never caught locally because the CI test hang
(fixed in #16) meant this branch was never actually compiled end to end
until now.

Also marks the intentionally-shadowed Fallback givens in FallbackSuite/
MetadataFallbackSuite's "normal given wins" tests as @unused - their
presence-but-non-resolution is exactly what's being asserted, which
-Wunused:all -Werror otherwise flags as dead code.

Verified: full `scala-cli test .` passes (0 failed except the pre-existing,
already-documented AnnotationCaptureSuite issue from #16).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

1 participant