Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mbr] Fix encmap boundary and method RVA lookup. #50248

Merged
merged 1 commit into from
Mar 26, 2021

Conversation

lambdageek
Copy link
Member

Two separate issues:

  1. When we process the EnC map, any tables after the last one that has an update gets an "enc_recs" pointer that's one past the last row of the table. (the enc_recs pointer is used to speed up relative address lookup). So at lookup time if enc_recs says to look past the end of the EnC map table, we know there won't be any updates - return -1.

  2. When looking for the updated RVA of a method, we need to go through every delta and find the latest one that has an update for the given method. The problem is that if a later generation doesn't have an update, we would take the NULL return value at face value and it would look like the method had no updates to its body - we would go back to using the original version from before any updates were applied. Instead now ignore lookup table misses and remember the last successful lookup. Fixes WebAssembly hot reload reverts to old version of a type #50190

Two separate issues:

1. When we process the EnC map, any tables after the last one that has an
update gets an "enc_recs" pointer that's one past the last row of the
table.  (the enc_recs pointer is used to speed up relative address lookup).  So
at lookup time if enc_recs says to look past the end of the EnC map table, we
know there won't be any updates - return -1.

2. When looking for the updated RVA of a method, we need to go through every
delta and find the latest one that has an update for the given method.  The
problem is that if a later generation doesn't have an update, we would take the
NULL return value at face value and it would look like the method had no
updates to its body - we would go back to using the original version from
before any updates were applied.  Instead now ignore lookup table misses and
remember the last successful lookup.  Fixes
dotnet#50190
@ghost
Copy link

ghost commented Mar 25, 2021

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

Issue Details

Two separate issues:

  1. When we process the EnC map, any tables after the last one that has an update gets an "enc_recs" pointer that's one past the last row of the table. (the enc_recs pointer is used to speed up relative address lookup). So at lookup time if enc_recs says to look past the end of the EnC map table, we know there won't be any updates - return -1.

  2. When looking for the updated RVA of a method, we need to go through every delta and find the latest one that has an update for the given method. The problem is that if a later generation doesn't have an update, we would take the NULL return value at face value and it would look like the method had no updates to its body - we would go back to using the original version from before any updates were applied. Instead now ignore lookup table misses and remember the last successful lookup. Fixes WebAssembly hot reload reverts to old version of a type #50190

Author: lambdageek
Assignees: -
Labels:

area-VM-meta-mono

Milestone: -

Copy link
Member

@thaystg thaystg left a comment

Choose a reason for hiding this comment

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

LGTM

/* if the table didn't have any updates in this generation and the
* table index is bigger than the last table that got updates,
* enc_recs will point past the last row */
if (index_map - 1 == encmap_rows)
Copy link
Contributor

Choose a reason for hiding this comment

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

And here you promised me no off by one math ;(

@lambdageek
Copy link
Member Author

/backport to release/6.0-preview3

@github-actions
Copy link
Contributor

Started backporting to release/6.0-preview3: https://github.com/dotnet/runtime/actions/runs/687493007

@lambdageek lambdageek mentioned this pull request Mar 25, 2021
51 tasks
@github-actions
Copy link
Contributor

@lambdageek backporting to release/6.0-preview3 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: [mbr] Fix encmap boundary and method RVA lookup.
Using index info to reconstruct a base tree...
M	src/mono/mono/metadata/loader.c
M	src/mono/mono/metadata/metadata-update.c
Falling back to patching base and 3-way merge...
Auto-merging src/mono/mono/metadata/metadata-update.c
CONFLICT (content): Merge conflict in src/mono/mono/metadata/metadata-update.c
Auto-merging src/mono/mono/metadata/loader.c
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 [mbr] Fix encmap boundary and method RVA lookup.
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@lambdageek
Copy link
Member Author

Manually backported to Preview 3 #50254

@lambdageek lambdageek merged commit c435557 into dotnet:main Mar 26, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Apr 25, 2021
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
@lambdageek lambdageek deleted the fix-gh-50190 branch March 19, 2022 16:45
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.

WebAssembly hot reload reverts to old version of a type
4 participants