Skip to content

fix: implement IFormattable on every value set so Native AOT with the .NET 11 SDK does not trap - #309

Merged
CaffeinatedCoder merged 2 commits into
release/10.xfrom
fix/299-aot-set-tostring-net11-sdk
Oct 19, 2026
Merged

CaffeinatedCoder merged 2 commits into
release/10.xfrom
fix/299-aot-set-tostring-net11-sdk

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #299

Against release/10.x, on top of #305 (which opened ## [10.1.0]) and #306. #299 is fixed only on release/10.x (main has the 11-line original, #291, in #292), so Closes will not act: close it by hand after the merge, with a link here.

Problem

ILCompiler 11 RC2 compiles the instantiating stub for the default IFormattable.ToString of IValueSetFactory<TSet, T> to a trap (dotnet/runtime#136073), and every set type's ToString() runs through that default. A net11.0 Native AOT consumer published with the .NET 11 SDK dies with SIGTRAP (exit 133, nothing on stderr) on the first value set ToString() — against the released 10.0.0 packages too, as #291 measured. 10.x is supported to 2028-11 and 11.x carries a breaking surface change (#275), so applications that move to .NET 11 and keep the 10.x packages are expected. Loud, not silent. This repository's CI has no .NET 11 SDK, so it did not see it (#297).

Change

Tests

SDK 11.0.100-rc.2.26504.105 and 10.0.402 installed with dotnet-install.sh into one scratch folder, put first on PATH; osx-arm64.

Before — SMOKE_AOT_SDK=11.0.100-rc.2.26504.105 test/consumer-smoke-test.sh <feed> with the feed packed from 48b9651, this branch's base without the change. The managed run of the net11.0 consumer prints every line; the native binary stops after aot-float64set, where #291 saw it stop, and the script reports:

==> aot: publishing with Native AOT (SDK 11.0.100-rc.2.26504.105)
      ...
      aot-wrapper-read={1,2}
      aot-stringset=["alpha","beta"] roundtrip
      aot-float64set=[2.9802322387695312e-08,9.999999999999999e+22] roundtrip
==> aot: asserting
  FAIL: the native binary exited with 133
  FAIL: AOT: a Float64Set<T> the program never constructs deserializes (expected 'aot-float64set-wrapper-read={2.9802322387695312e-08,9.999999999999999e+22}' in aot.native.out)
  ... (every later assertion, aot-set-tostring-every-family among them)
consumer smoke test FAILED

After — the same command with the feed packed from this branch:

==> aot: publishing with Native AOT (SDK 11.0.100-rc.2.26504.105)
      ...
      aot-set-tostring-every-family={a} {00000000-0000-0000-0000-000000000000} {1} {1} {1} {1.5} {0.5} {0.5} {2026-01-01} {09:30:00.0000000} {2026-01-01T09:30:00.0000000Z} {2026-01-01T09:30:00.0000000+00:00} {2026-01-01} {09:30:00} {2026-01-01T09:30:00} {2026-01-01T09:30:00Z} {2026-01}
==> aot: asserting
  ok: the native binary ran to the end
  ok: no trim/AOT warnings from the packages
      ...
consumer smoke test passed (10.1.0)

75 assertions, none failing, across the four consumers.

Without SMOKE_AOT_SDK, from a folder holding only SDK 10.0.402 (the net10.0 consumer with ILCompiler 10, what CI publishes): passes with this branch's feed, aot-set-tostring-every-family included, as it did before the change.

dotnet test, all green:

Project Result
CodoMetis.ValueRanges.Tests 1391 / 1391
CodoMetis.ValueRanges.NodaTime.Tests 238 / 238
CodoMetis.ValueRanges.EFCore.PostgreSQL.Tests 289 / 289
CodoMetis.ValueRanges.EFCore.PostgreSQL.NodaTime.Tests 83 / 83
CodoMetis.ValueRanges.AspNetCore.Tests 92 / 92
CodoMetis.ValueRanges.Conventions.Tests 403 / 403
the two integration projects skipped locally (no Docker); CI runs them on PostgreSQL 16 and 18

🤖 Generated with Claude Code

… .NET 11 SDK does not trap

ILCompiler 11 RC2 compiles the instantiating stub for the default
IFormattable.ToString of IValueSetFactory<TSet, T> to a trap, and every set
type's ToString() ran through that default, so a net11.0 Native AOT consumer
of the released 10.0.0 packages ended with SIGTRAP (exit 133, nothing on
stderr) on the first value set ToString. #299 is the 10.x issue; #291 measured
it on the 11 line, against the unchanged 10.0.0 package too, and reported it
upstream as dotnet/runtime#136073.

Every set type - the twelve core families and their wrapper arities, and the
five NodaTime families - implements IFormattable.ToString explicitly as
SetFormat.Format<TSet, T>(this, format, provider), and its ToString() calls
SetFormat.Format directly, so the interface's default is never the
implementation a compiled consumer runs. The interface keeps its default.
Explicit interface implementations leave the public surface unchanged, and
the ApiCompat baseline against 10.0.0 passes in dotnet pack. The change is the
one PR #292 made on main; #292 is one commit (231f23a) holding the whole .NET
11 retarget, so this is a hand-extracted commit naming it rather than a
cherry-pick -x. The clone sweep (tools/oracles.cs clones) reports no new
divergence: every family changed the same way.

test/consumer-smoke-test.sh gains SMOKE_AOT_SDK, which pins the AOT consumer
to an installed .NET SDK through a global.json written beside it before
dotnet new, and targets that SDK's framework, so the publish runs that SDK's
ILCompiler over the net10.0 packages. The header says how to run it with a
.NET 11 SDK installed beside the .NET 10 one the repository's global.json
needs. The AOT leg now also fails on a non-zero exit of the native binary, and
one case prints every value set family's ToString. Measured with SDK
11.0.100-rc.2.26504.105 on osx-arm64: against a pack of the branch without
this change (48b9651) the native binary exited with 133 after printing
aot-float64set, where #291 saw it stop; with this change it runs to the end,
the new case prints all seventeen families, and the smoke test passes. The
.NET 10 SDK run, which is what CI does, is unchanged and green.

Issue #299, fixed on release/10.x only; closed by hand after the merge, since
a closing keyword acts only on main.

Found-By: SM
Defect-Class: PKG
Co-Authored-By: Claude Fable 5.1 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 10.1.0 milestone Oct 19, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working area/value-sets Value set families and wrapper arities package/nodatime Affects CodoMetis.ValueRanges.NodaTime area/aot Native AOT and trimming package/core Affects CodoMetis.ValueRanges severity/high Wrong results, crash or failed writes in a realistic scenario labels Oct 19, 2026
Resolves the core changelog conflict with #308: the 10.1.0 section opens with
Changed answers (#300), then Fixed (#299).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@CaffeinatedCoder
CaffeinatedCoder force-pushed the fix/299-aot-set-tostring-net11-sdk branch from 1a9c970 to 089863c Compare October 19, 2026 12:11
@CaffeinatedCoder
CaffeinatedCoder merged commit 4233dea into release/10.x Oct 19, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/299-aot-set-tostring-net11-sdk branch October 19, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/aot Native AOT and trimming area/value-sets Value set families and wrapper arities bug Something isn't working package/core Affects CodoMetis.ValueRanges package/nodatime Affects CodoMetis.ValueRanges.NodaTime severity/high Wrong results, crash or failed writes in a realistic scenario

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant