Skip to content

[mono][interp] Fix null dereference for a calli with a vararg signature - #134133

Open
PavlNekrasov wants to merge 2 commits into
dotnet:mainfrom
PavlNekrasov:fix/interp-transform-call-vararg-null-deref
Open

PavlNekrasov wants to merge 2 commits into
dotnet:mainfrom
PavlNekrasov:fix/interp-transform-call-vararg-null-deref

Conversation

@PavlNekrasov

Copy link
Copy Markdown
Contributor

fix #134129

Only re-resolve the signature when target_method is not NULL

Signed-off-by: p.nekrasov@fobos-nt.ru
Signed-off-by: morgonf@altlinux.org

Problem:
In interp_transform_call() target_method stays NULL for a calli, and
every other use of it in the function is guarded by a NULL check. The
vararg branch is not, and mono_method_get_signature_checked()
dereferences its first argument, so a calli with a vararg signature
crashes the transform.

Solution:
Only re-resolve the signature when target_method is not NULL. Nothing has
to be re-resolved for a calli, because csignature is already the call
site signature taken from the standalone signature token.

Signed-off-by: p.nekrasov@fobos-nt.ru
Signed-off-by: morgonf@altlinux.org
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Sep 17, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 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: @vitek-karas, @BrzVlad, @kotlarmilos
See info in area-owners.md if you want to be subscribed.

@PavlNekrasov PavlNekrasov changed the title Fix: DEREF_AFTER_NULL.EX [mono][interp] Fix null dereference for a calli with a vararg signature Sep 17, 2026

@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 looks like it will fix the missing null check but still fail later. The change needs a working test to verify.

Problem:
Guarding the NULL only moves the failure: the call then emits MINT_CALLI, and MINT_INIT_ARGLIST, the first instruction of every vararg method, reads the call site signature from the caller assuming MINT_CALL_VARARG is there. MINT_CALLI is 4 slots wide instead of 6, so a bogus data_items index is used as a MonoMethodSignature *.
Solution: Report a vararg calli as not supported next to the existing thiscall check. target_method is only NULL for a calli, so the signature re-resolution needs no guard. Added a test.
Signed-off-by: p.nekrasov@fobos-nt.ru
Signed-off-by: morgonf@altlinux.org
@PavlNekrasov

Copy link
Copy Markdown
Contributor Author

This looks like it will fix the missing null check but still fail later. The change needs a working test to verify.

You were right: the null check alone just moves the crash into init_arglist(), so the PR now rejects a vararg calli as not supported and adds a test.

@PavlNekrasov

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree company="Fobos-NT"

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

Labels

area-Codegen-Interpreter-mono community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Null pointer dereference in interp_transform_call()

2 participants