Skip to content

[cDAC] Handle targets without ReJIT in method versionability - #135054

Open
radekdoulik wants to merge 3 commits into
dotnet:mainfrom
radekdoulik:radekdoulik-cdac-optional-rejit
Open

radekdoulik wants to merge 3 commits into
dotnet:mainfrom
radekdoulik:radekdoulik-cdac-optional-rejit

Conversation

@radekdoulik

Copy link
Copy Markdown
Member

Handle a missing ReJIT contract in RuntimeTypeSystem.IsVersionable for targets
built without profiling support. Non-tiered methods return false; the tiering
fast path is unchanged. Invalid advertised contracts and target-read errors
still propagate.

Adds four-architecture tests for contract availability, tiering, versioning
support and error propagation, and updates the contract specification.

Validation: managed cDAC build and 3,260 unit tests passed; generated contract
docs are up to date. The missing-ReJIT cases fail without the fix.
NativeAOT publishing and live-browser tests were not rerun for this patch.

Note

Prepared with GitHub Copilot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

@lewing lewing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This matches native: MethodDesc::IsEligibleForReJIT returns false without FEATURE_REJIT, and the descriptor only advertises ReJIT under PROFILING_SUPPORTED. Treating ContractMissingException as "feature absent" while rethrowing unrecognized versions and read failures is the right split. Gating on the contract rather than on architecture fits here, because the driver is the profiler build setting, not WASM itself. I ran IsVersionable tests locally at 7679c6f: 28/28 pass.

One related gap: CoreCLRContracts.ValidateForDataAccess still calls Validate<IReJIT>(registry) unconditionally, so a target built without profiling support still fails validation before IsVersionable is reached. #135044 had to gate Validate<IDebugger> on WASM for the same reason. Either gate it on the contract being advertised or note it as a follow-up. The SOSDacImpl callers of Contracts.ReJIT have the same assumption, but they aren't reachable on WASM today.

Note

This review was generated with assistance from GitHub Copilot.

Comment on lines +2001 to +2006
if (!_target.Contracts.TryGetContract(out IReJIT reJit, out System.Exception? failure))
{
if (failure is ContractMissingException)
return false;
throw failure;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if (!_target.Contracts.TryGetContract(out IReJIT reJit, out System.Exception? failure))
{
if (failure is ContractMissingException)
return false;
throw failure;
}
if (!_target.Contracts.TryGetContract(out IReJIT reJit)
{
return false;
}

Use overload that takes care of throwing the exceptions?

radekdoulik and others added 2 commits October 2, 2026 13:29
Make the one-output TryGetContract overload return false only for missing contracts, keeping the two-output overload available for inspecting failures. Use it in IsVersionable and cover unsupported versions and creator failures.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Treat ReJIT as optional only when it is not advertised. Keep version errors and required-contract checks intact, and validate availability without instantiating ReJIT. Cover absence and unsupported versions across the four mock architectures.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

@rcj1 rcj1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM mod Jan's comment

return TryGetContract(out contract, out _);
if (!TryGetContract(out contract, out System.Exception? failureException))
{
if (failureException is ContractMissingException)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would expect TryGetContract(out contract, out System.Exception? failureException) to always return false when the requested contract is missing. Is that not the case? If there is a bug, should it be fixed inside TryGetContract(out contract, out System.Exception? failureException) implementation instead?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants