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

[RuntimeAsync] Some issues with preserving value of a nullable struct with mix of ref/value fields across a suspension point. #3043

Open
VSadov opened this issue Mar 16, 2025 · 2 comments
Labels
area-async Runtime generate async state machines

Comments

@VSadov
Copy link
Member

VSadov commented Mar 16, 2025

I am not completely sure if this is related to Nullable. Nullable could be special if there was boxing, but this is just a local variable losing its value after Yield. No boxing is involved in this case.
Possibly it is a more general issue with liveness/storing/restoring of mixed value/ref fields of a struct, just a repro happened to involve nullable.

== To repro:
In shared-generics.cs uncomment 2 scenarios marked with
// TODO: uncomment to repro https://github.com/dotnet/runtimelab/issues/3043 and run the test.

The test will fail. It looks like we lose the value here:

    public static async2 Task<T> StaticReturnClassType(T value)
    {
// value != null 
        await Task.Yield();
// value == null
        return value;
    }

Also, I think, while modifying the test with Console.WriteLine(value) in various places to see where exactly the value is lost, I think I have seen the scenario to pass, but lost track to what shape the test was and can't make it pass again. There is a thought that we may be dealing with uninitialized data, maybe...

@VSadov VSadov added the area-async Runtime generate async state machines label Mar 16, 2025
@VSadov
Copy link
Member Author

VSadov commented Mar 16, 2025

CC: @jakobbotsch

@jakobbotsch
Copy link
Member

This looks like a problem around certain implicit byref parameters. I can open a fix after #3042 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-async Runtime generate async state machines
Projects
None yet
Development

No branches or pull requests

2 participants