-
Notifications
You must be signed in to change notification settings - Fork 4k
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
BUG: TypeLoadException generated using 3.2.0-beta1-19227-04 #35324
Comments
This may be of interest to @tannergooding and @RikkiGibson since it seems related to issue #31439 which was a recent bug fix. |
This is present also in latest: 3.2.0-beta1-19229-02 |
Will have a look. Is there any additional error info contained in the exception? edit: I can repro this in the IDE and see the message:
This seems to happen whether or not the |
Actually I find that even the following program gets TypeLoadException: using System;
namespace ConsoleApp9
{
public struct Item
{
internal ItemHolder<Item> next;
internal ItemHolder<Item> prev;
}
public struct ItemHolder<T> { }
class Program
{
static void Main(string[] args)
{
Console.WriteLine(new Item());
}
}
} But this one does not: using System;
namespace ConsoleApp9
{
public class Item
{
internal ItemHolder<Item> next;
internal ItemHolder<Item> prev;
}
public class ItemHolder<T> { }
class Program
{
static void Main(string[] args)
{
Console.WriteLine(new Item());
}
}
} |
It appears this is a known issue noted in dotnet/coreclr#20220 |
@RikkiGibson - I got the impression when looking at this that the compiler may be assuming that structs which refer in any way to themselves are invalid because structs are laid out as values not references to values and this clearly leads to infinite recursion. Of course exposing only a |
This appears to be a runtime issue, and not related to use of |
Closing as this is dotnet/coreclr#20220 and https://github.com/dotnet/coreclr/issues/7957 |
3.2.0-beta1-19227-04:
Create console app that references the type:
Item
This was found using VS 2019 (16.0.2) in which I added the beta compiler nuget packages to my solution/projects and set C# build to 8.0 (beta).
I've created a simple way to repro this, the actual code that led to this crash is more involved (e.g. the actual code dynamically computes the
T*
pointer here it just returnsnull
) but the samplestruct
seems to accurately recreate the problem, in my case the typeItem
is in a separate class library assembly (also .Net Standard 2.0) no idea if this is a factor though as I haven't tried it.An instance of the type should be created without problems:
TypeLoadException:
Here's the struct - it compiles fine with this beta build and earlier ones, I have tested the runtime fault and it's present in this version and also in 3.1.0-beta3-19213-02 if I recall.
If we change this to something like this, we do not get the runtime fault:
by the way returning a ref rather than a pointer leads to the same exception:
The text was updated successfully, but these errors were encountered: