Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Add a test for #2260 - #2263

Merged
vitek-karas merged 2 commits into
dotnet:mainfrom
vitek-karas:TestForSweepNullRef
Sep 8, 2021
Merged

vitek-karas merged 2 commits into
dotnet:mainfrom
vitek-karas:TestForSweepNullRef

Conversation

@vitek-karas

Copy link
Copy Markdown
Member

This uncovers a null ref in sweepstep.
The test is order dependent:

  • Assembly (librarywithnonemtpy) has a virtual method which referes to type from second library (library). This processes the type reference.
  • The type is removed from library
  • The virtual method is re-processed again -> hits a type def which does not belong to any assembly/scope

For this to happen the virtual method must be processed after the type has been removed.
This also requires the method to be meant for removal later on (the body will be rewritten to throw), since otherwise the type would have been marked.
This also requires the library with the removed type to be kept (so something else in it must be kept).

This uncovers a null ref in sweepstep.
The test is order dependent:
- Assembly (librarywithnonemtpy) has a virtual method which referes to type from second library (library). This processes the type reference.
- The type is removed from library
- The virtual method is re-processed again -> hits a type def which does not belong to any assembly/scope

For this to happen the virtual method must be processed after the type has been removed.
This also requires the method to be meant for removal later on (the body will be rewritten to throw), since otherwise the type would have been marked.
This also requires the library with the removed type to be kept (so something else in it must be kept).
@vitek-karas vitek-karas added this to the .NET 7.0 milestone Sep 7, 2021
@vitek-karas
vitek-karas requested a review from sbomer September 7, 2021 09:30
@vitek-karas vitek-karas self-assigned this Sep 7, 2021

namespace Mono.Linker.Tests.Cases.Inheritance.AbstractClasses.NoKeptCtor.OverrideRemoval.Dependencies
{
public class OverrideOfAbstractIsKeptNonEmptyLibraryWithNonEmpty :

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.

nit: I'm not sure what the "non-empty" in NonEmptyLibrary or WithNonEmpty refer to - maybe the names could be simplified?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The idea was to keep the names starting with the name of the test - so that it's easy to tell which dependencies belong to which test.

@vitek-karas
vitek-karas merged commit 43fb979 into dotnet:main Sep 8, 2021
@vitek-karas
vitek-karas deleted the TestForSweepNullRef branch September 8, 2021 08:35
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
This uncovers a null ref in sweepstep.
The test is order dependent:
- Assembly (librarywithnonemtpy) has a virtual method which referes to type from second library (library). This processes the type reference.
- The type is removed from library
- The virtual method is re-processed again -> hits a type def which does not belong to any assembly/scope

For this to happen the virtual method must be processed after the type has been removed.
This also requires the method to be meant for removal later on (the body will be rewritten to throw), since otherwise the type would have been marked.
This also requires the library with the removed type to be kept (so something else in it must be kept).

Commit migrated from dotnet/linker@43fb979
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.

3 participants