Skip to content

Build: refuse a DLR checkout that lacks a patch (Backtrace9, #132) - #151

Merged
Largo merged 2 commits into
masterfrom
claude/fix-backtrace9-132
Nov 8, 2026
Merged

Largo merged 2 commits into
masterfrom
claude/fix-backtrace9-132

Conversation

@Largo

@Largo Largo commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Fixes #132

Cause

Backtrace9 fails exactly when IronRuby is built against a DLR checkout without 0103-reflection-call-rethrow.patch. Without it the interpreter rethrows what a method called through MethodInfo.Invoke raised (a Ruby method with ~10+ parameters) with throw inner, which restarts the CLR stack trace and drops the raising method's frame. Built against a DLR with only 0103 reverted, the test prints caller_of_many / Backtrace9.rb / CompilerTest: the "extra caller_of_many frame first" from the issue.

The failing "fresh container" was a cloud session whose DLR had been patched before 0103 landed (2026-11-06); ecc3390d already has the test and the patch file, so a DLR patched from an earlier tree fails it, while CI applies every patch to a fresh checkout and passes. Nothing noticed: only make test ran Util/check-dlr-patches.sh, and only to warn.

With every patch applied the runtime is right: frames many, caller_of_many, top level, the order CRuby 4.0 gives (Object#many, Object#caller_of_many, <main>). It is not JIT- or order-dependent. Backtrace9 passed in all of these:

  • net8.0 and net10.0, isolated (20/20 runs) and inside the full suite
  • with DOTNET_TieredCompilation=0, TC_QuickJit=0, ReadyToRun=0, TieredPGO=0, JitMinOpts=1, TC_CallCountThreshold=1, and server GC
  • with the reflection invoker warmed up (5 calls before the checked one)
  • in a fresh mcr.microsoft.com/dotnet/sdk:10.0-noble container (runtime 10.0.14), isolated and in the full suite

Change

  • Building IronRuby.dll runs Util/check-dlr-patches.sh against DlrSourceDir and fails, naming the missing patch, when the DLR lacks one. It runs off Windows only, where sh and git can be counted on. -p:CheckDlrPatches=false skips it. A DLR that is not a git checkout (a source tarball) passes, as before.
  • check-dlr-patches.sh also passes a DLR copied into some other repository (make-dlr-copy.sh's), which is not a DLR checkout it can check.
  • Docs: CLAUDE.md and Build/dlr-patches/README.md. Backtrace9's comment now says what it shows without the patch.

The test is unchanged: its expectation is right.

Checked

  • The build fails against a DLR with 0103 reverted (also with a backslash DlrSourceDir), and passes with -p:CheckDlrPatches=false and with all patches applied.
  • Full IronRuby.Tests suite (net10.0): PASSED on the host. In the fresh container Backtrace9 passed in the full run too; 8 other tests failed there for container reasons, not this change: the SDK image has libz.so.1 but no libz.so, which Zlib loads (Zlib_*, NetHttp_*, Puma_Tls1), and dotnet ran as PID 1 without --init (Process_SpawnKill1: ECHILD).

Not in this PR

IronRuby labels these frames many / caller_of_many and the top level without in, while CRuby 4.0 says Object#many / <main> (the 3.4 label format). That is wider than this test.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Build Improvements
    • On non-Windows systems, builds now check for required DLR patches and stop with an error if any are missing. The check can be skipped with -p:CheckDlrPatches=false.
    • The check is skipped when the specified repository is not a DLR checkout.
  • Documentation
    • Updated build guidance to describe the patch check and its behavior.

Backtrace9 failed in some Linux environments with the backtrace starting at
caller_of_many instead of many (issue 132). Those builds were against a DLR
checkout patched before 0103-reflection-call-rethrow.patch landed: without
it the interpreter rethrows what a method called through MethodInfo.Invoke
raised with `throw inner`, which restarts the CLR stack trace and drops the
raising method's frame. The output is exactly that: built against a DLR
with 0103 reverted, Backtrace9 prints caller_of_many / Backtrace9.rb /
CompilerTest. With every patch applied the frames are many, caller_of_many,
the top level - the order CRuby 4.0 gives (Object#many,
Object#caller_of_many, <main>) - on net8.0 and net10.0, isolated and in the
full suite, with tiered compilation off, MinOpts, PGO off, a call-count
threshold of 1, a warmed-up reflection invoker, and in a fresh
dotnet/sdk:10.0-noble container. So the runtime is right and the test is
not environment-dependent; the environment was a stale DLR.

A DLR checkout is patched once and nothing noticed when it fell behind:
only `make test` ran Util/check-dlr-patches.sh, and only to warn. Building
IronRuby.dll now runs it (off Windows, where sh and git may be missing) and
fails, naming the missing patch; -p:CheckDlrPatches=false skips it. The
script also passes a DLR copied into another repository
(make-dlr-copy.sh's), which is not a DLR checkout to check.

Checked: the build fails against a DLR with 0103 reverted (also with a
backslash DlrSourceDir), passes with -p:CheckDlrPatches=false and with all
patches applied; full IronRuby.Tests suite passes.

Fixes #132

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 48 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 53 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2bd237e and 3bcce51.

Files selected for processing: 1

  • Util/check-dlr-patches.sh

No actionable comments were generated in the recent review.

Walkthrough

The build now checks for missing DLR patches before compilation on non-Windows systems. The check can be skipped with -p:CheckDlrPatches=false. The script exits successfully when the target repository does not contain the DLR source directory.

Changes: DLR patch check

Layer / File(s) Summary
Build check and documented behavior
Src/Ruby/Ruby.csproj, Util/check-dlr-patches.sh, Build/dlr-patches/README.md, CLAUDE.md, Src/IronRuby.Tests/Runtime/BacktraceTests.cs
The build project runs the patch-check script before compilation on non-Windows systems unless the check is disabled. The script exits successfully when the target repository lacks src/core/Microsoft.Dynamic. Documentation and the Backtrace9 comment describe the check and the missing-patch behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • Largo/ironruby#67: Creates the patch-check script that this PR invokes and updates.

Suggested reviewers: claude

Merge Risk: Low · previous review 2bd23

A patched DLR copied inside another DLR repository can be rejected by the build. The check can be skipped as a workaround.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the build now refuses a DLR checkout that lacks a required patch. It also names the test and issue it relates to. The raw summary, objectives, and changed files (Ruby.…
Linked Issues check Passed Issue #132 asks to reproduce the extra caller_of_many frame, compare with CI, and either make the frame list deterministic or make the test independent of it. The PR does not edit the test or the fram…
Out of Scope Changes check Passed All changed files relate to the build-time DLR patch guard that resolves #132. Src/Ruby/Ruby.csproj adds the guard target. Util/check-dlr-patches.sh adds a clean exit for a directory that is not a DLR…
Full details: Title check

Explanation

The title names the main change: the build now refuses a DLR checkout that lacks a required patch. It also names the test and issue it relates to. The raw summary, objectives, and changed files (Ruby.csproj check target, check-dlr-patches.sh, docs, and the Backtrace9 test note) all match this description. The title is 66 characters and 11 words, which is within the expected length for a short, single-sentence title.

Full details: Linked Issues check

Explanation

Issue #132 asks to reproduce the extra caller_of_many frame, compare with CI, and either make the frame list deterministic or make the test independent of it. The PR does not edit the test or the frame list. It takes a different route. The author reports that the frame list is correct when all DLR patches are applied, and that the failure occurs when 0103-reflection-call-rethrow.patch is missing. Src/Ruby/Ruby.csproj adds the target IronRubyCheckDlrPatches (BeforeTargets CoreCompile). It runs Util/check-dlr-patches.sh against DlrSourceDir off Windows and fails the build when a patch is missing. Util/check-dlr-patches.sh reverse-applies the patch series from a copy of the touched files, newest first, and names the first missing patch. Together these make a default build against a stale DLR fail. The frame list therefore reflects one defined DLR state for any build that completes. Limits: the check does not run on Windows, and it can be skipped with -p:CheckDlrPatches=false. Under those conditions a test run against an unpatched DLR can still show the extra frame. The issue reports that the Windows run passes, so this limit does not block the issue's reported failure. I did not re-run the reproduction. The reproduction and the JIT-configuration results are author claims, not repository evidence.

Full details: Out of Scope Changes check

Explanation

All changed files relate to the build-time DLR patch guard that resolves #132. Src/Ruby/Ruby.csproj adds the guard target. Util/check-dlr-patches.sh adds a clean exit for a directory that is not a DLR checkout (a source tarball, or a DLR copied by Util/aot/NativeAot/make-dlr-copy.sh). Without this exit, the guard would block valid builds. CLAUDE.md and Build/dlr-patches/README.md document the new behavior and the -p:CheckDlrPatches=false opt-out. Src/IronRuby.Tests/Runtime/BacktraceTests.cs changes only a summary comment, and the test logic is unchanged. No unrelated code changes appear in the reviewed diff for these files.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 468c0db and 2bd237e.

Files selected for processing: 5

  • Build/dlr-patches/README.md
  • CLAUDE.md
  • Src/IronRuby.Tests/Runtime/BacktraceTests.cs
  • Src/Ruby/Ruby.csproj
  • Util/check-dlr-patches.sh

Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

…deRabbit on #151)

A DLR copied into a directory inside a DLR checkout found that checkout as
its git top level and was checked against the outer checkout's files: the
build could reject a patched copy because the outer checkout was stale
(CodeRabbit's merge-risk note). A src/core given directly is now checked
only when it is the top level's own src/core; any other copy passes, as a
copy in another repository already did.

Checked: the script exits 0 for a patched checkout (given as its root or
src/core), 1 for a stale one (root, src/core or src/core/Microsoft.Dynamic),
and 0 for a copy of src/core inside the stale checkout; IronRuby.dll builds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Largo

Largo commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai Your merge-risk note (a patched DLR copied inside another DLR checkout could be rejected) is addressed in 3bcce51: a src/core passed directly is checked only when it is its git top level's own src/core; any other copy passes, as a copy inside a different repository already did.

@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

Analysis chain

Script executed:

#!/bin/bash
set -u
printf '%s\n' '--- Current revision ---'
git rev-parse HEAD
printf '%s\n' '--- Commit summary and patch ---'
git show --format=fuller --stat 3bcce51a --
git show --format= --no-ext-diff 3bcce51a -- Util/check-dlr-patches.sh
printf '%s\n' '--- Current script outline ---'
ast-grep outline Util/check-dlr-patches.sh --items all 2>&1 || true
printf '%s\n' '--- Current script ---'
nl -ba Util/check-dlr-patches.sh | sed -n '1,240p'
printf '%s\n' '--- Direct src/core references ---'
rg -n -C 3 'check-dlr-patches\.sh|git top.level|src/core' --glob '*.sh' --glob '*.md' --glob '*.csproj' | head -200

Length of output: 19220


@Largo Thanks. I inspected 3bcce51a. A directly supplied src/core copy now exits before the script checks the enclosing DLR checkout. The checkout’s own src/core remains subject to the patch check.

This addresses the reported merge risk. I did not run the script or build.

You are interacting with an AI system.

@Largo
Largo merged commit 7abc049 into master Nov 8, 2026
8 checks passed
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.

Backtrace9 fails on Linux in a fresh container (extra caller_of_many frame)

1 participant