Skip to content

[mono][interp] Fix incorrect stack type information#94923

Merged
lewing merged 3 commits intodotnet:mainfrom
BrzVlad:fix-interp-devirt-bbstate
Nov 19, 2023
Merged

[mono][interp] Fix incorrect stack type information#94923
lewing merged 3 commits intodotnet:mainfrom
BrzVlad:fix-interp-devirt-bbstate

Conversation

@BrzVlad
Copy link
Member

@BrzVlad BrzVlad commented Nov 17, 2023

Assume we have a basic block that it is a forward branch destination, then its stack type information will be initialized at the moment of branching (let's say there is a value of type Obj1). If later in the code we reach this bblock by falling through (let's say the current stack contains a value of Obj2), the current stack state will be copied from the original state, with the type Obj1. If later on we do a virtual call, we will try to devirtualize it as if this is Obj1 which is incorrect, since the fallthrough path would produce an Obj2.

This commit adds missing checks for removing type information if we have different types on the execution types on incoming paths.

Fixes #94773

Assume we have a basic block that it is a forward branch destination, then its stack type information will be initialized at the moment of branching (let's say there is a value of type Obj1). If later in the code we reach this bblock by falling through (let's say the current stack contains a value of Obj2), the current stack state will be copied from the original state, with the type Obj1. If later on we do a virtual call, we will try to devirtualize it as if this is Obj1 which is incorrect, since the fallthrough path would produce an Obj2.

This commit adds missing checks for removing type information if we have different types on the execution types on incoming paths.
@ghost
Copy link

ghost commented Nov 17, 2023

Tagging subscribers to this area: @BrzVlad, @kotlarmilos
See info in area-owners.md if you want to be subscribed.

Issue Details

Assume we have a basic block that it is a forward branch destination, then its stack type information will be initialized at the moment of branching (let's say there is a value of type Obj1). If later in the code we reach this bblock by falling through (let's say the current stack contains a value of Obj2), the current stack state will be copied from the original state, with the type Obj1. If later on we do a virtual call, we will try to devirtualize it as if this is Obj1 which is incorrect, since the fallthrough path would produce an Obj2.

This commit adds missing checks for removing type information if we have different types on the execution types on incoming paths.

Fixes #94773

Author: BrzVlad
Assignees: BrzVlad
Labels:

area-Codegen-Interpreter-mono

Milestone: -

@lewing
Copy link
Member

lewing commented Nov 17, 2023

lets backport this when ready

@lewing lewing merged commit 86dad38 into dotnet:main Nov 19, 2023
@lewing
Copy link
Member

lewing commented Nov 19, 2023

/backport to release/8.0-staging

@github-actions
Copy link
Contributor

Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/6918089418

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[mono][interp] memory access out of bounds in string manipulation

3 participants