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

Assertion failed: Struct fields can only be accessed with a pointer on the stack #1224

Closed
mmusu3 opened this issue Jul 21, 2018 · 3 comments
Closed
Labels
Bug Decompiler The decompiler engine itself

Comments

@mmusu3
Copy link

mmusu3 commented Jul 21, 2018

Using ILSpy 4
Assertion fails when compiled in both Debug and Release.

Source:

class AssertTest
{
    struct DataStruct { }

    struct WrapperStruct
    {
        internal DataStruct Data;
    }

    class SomeClass
    {
        internal WrapperStruct DataWrapper;
    }

    SomeClass someClass;

    public void Test()
    {
        GetMember(() => someClass.DataWrapper.Data);
    }

    public static MemberInfo GetMember<T>(Expression<Func<T>> p) => default;
}
@dgrunwald dgrunwald added Bug Decompiler The decompiler engine itself labels Jul 25, 2018
@cshung
Copy link
Contributor

cshung commented Jul 29, 2018

Hello maintainers, I am interested in fixing this bug.

@dgrunwald
Copy link
Member

Great! I haven't looked at it in detail, but believe the bug here is in TransformExpressionTrees producing an invalid ILAst in this case.
If you haven't seen the ILAst yet, check out this comment.

You can decompile the equivalent function using a lambda instead of expression tree, to see how the ILAst should look in this situation.

@cshung
Copy link
Contributor

cshung commented Jul 29, 2018

Thanks for the idea, I will look into the ILAst of the lambda.

I think I have an idea about what gone wrong in TransformExpressionTrees , here is what I am thinking right now.

https://github.com/icsharpcode/ILSpy/compare/master...cshung:dev/andrewau/1224?expand=1

cshung added a commit to cshung/ILSpy that referenced this issue Jul 29, 2018
cshung added a commit to cshung/ILSpy that referenced this issue Jul 29, 2018
siegfriedpammer added a commit that referenced this issue Aug 1, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Decompiler The decompiler engine itself
Projects
None yet
Development

No branches or pull requests

4 participants