-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Poison address-exposed user variables in debug #54685
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4f161de
Poison address exposed user variables in debug code
jakobbotsch 7e6b5cf
Run jit-format
jakobbotsch 1f3d654
Use named scratch register and kill it in LSRA
jakobbotsch 5122ec0
Enable it unconditionally for testing purposes
jakobbotsch 8acf5ea
Remove unnecessary modified reg on ARM
jakobbotsch 94fe61d
Fix OSR and get rid of test code
jakobbotsch 4db5c5f
Remove a declaration
jakobbotsch 90b0133
Undo modified comment and use modulo instead of and
jakobbotsch 3d9fd8c
Add a test
jakobbotsch 8c56578
Rephrase comment
jakobbotsch 302bfba
Disable poisoning test on mono
jakobbotsch a63669e
Remove outdated line
jakobbotsch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| using System; | ||
| using System.Runtime.CompilerServices; | ||
|
|
||
| public class Program | ||
| { | ||
| [SkipLocalsInit] | ||
| public static unsafe int Main() | ||
| { | ||
| bool result = true; | ||
|
|
||
| int poisoned; | ||
| Unsafe.SkipInit(out poisoned); | ||
| result &= VerifyPoison(&poisoned, sizeof(int)); | ||
|
|
||
| GCRef zeroed; | ||
| Unsafe.SkipInit(out zeroed); | ||
| result &= VerifyZero(Unsafe.AsPointer(ref zeroed), Unsafe.SizeOf<GCRef>()); | ||
|
|
||
| WithoutGCRef poisoned2; | ||
| Unsafe.SkipInit(out poisoned2); | ||
| result &= VerifyPoison(&poisoned2, sizeof(WithoutGCRef)); | ||
|
|
||
| return result ? 100 : 101; | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| private static unsafe bool VerifyPoison(void* val, int size) | ||
| => AllEq(new Span<byte>(val, size), 0xCD); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| private static unsafe bool VerifyZero(void* val, int size) | ||
| => AllEq(new Span<byte>(val, size), 0); | ||
|
|
||
| private static unsafe bool AllEq(Span<byte> span, byte byteVal) | ||
| { | ||
| foreach (byte b in span) | ||
| { | ||
| if (b != byteVal) | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| private struct GCRef | ||
| { | ||
| public object ARef; | ||
| } | ||
|
|
||
| private struct WithoutGCRef | ||
| { | ||
| public double ADouble; | ||
| public int ANumber; | ||
| public float AFloat; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <DebugType>PdbOnly</DebugType> | ||
| <Optimize>False</Optimize> | ||
| <AllowUnsafeBlocks>True</AllowUnsafeBlocks> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="$(MSBuildProjectName).cs" /> | ||
| </ItemGroup> | ||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.