Skip to content

Access Violation #773

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

Open
KC-Cygnia opened this issue Feb 10, 2025 · 6 comments
Open

Access Violation #773

KC-Cygnia opened this issue Feb 10, 2025 · 6 comments

Comments

@KC-Cygnia
Copy link

KC-Cygnia commented Feb 10, 2025

When mapping to an Input application crashes with no info when doing a multilevel mapping on EF Classes
[SupplyParameterFromForm] public InputModel Input { get; set; } = new();

public class InputModel : myClass
    {

    }
public class myClass
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public DateTime DateTimeStamp { get; set; } = DateTime.Now;
        public List<Thing>? Things{ get; set; }
    }
public class Thing
    {
        public int Id { get; set; }
        public string ThingName { get; set; }
        public DateTime DateTimeStamp { get; set; } = DateTime.Now;
        public List<AnotherThing>? AnotherThings{ get; set; }
        public myClass myClass { get; set; }
        public int myClassId { get; set; }
        
    }
public class AnotherThing    
{
        public int Id { get; set; }
        public string AnotherThingName { get; set; }
        public DateTime DateTimeStamp { get; set; }
        public Thing Thing { get; set; }
        public int ThingId { get; set; }
    }

Crashes on:

Input = _myClass.Adapt<InputModel>();

Crash error: The program '[53536] MyApp.exe' has exited with code 3221225477 (0xc0000005) 'Access violation'.

@DocSvartz
Copy link

Hello @KC-Cygnia
Please indicate the version of Mapster you are using?
If possible, check on the latest pre-release version.

@KC-Cygnia
Copy link
Author

Hi @DocSvartz
I'm using 7.4.0

@KC-Cygnia
Copy link
Author

Hello @KC-Cygnia Please indicate the version of Mapster you are using? If possible, check on the latest pre-release version.

Pre release version 7.4.2-pre02 also crashes

@DocSvartz
Copy link

possible linked with #720

@andrerav
Copy link
Contributor

@KC-Cygnia Based on your class structure (which appears to be recursive) I'm going to go out on a limb and guess that you are encountering circular recursion which leads to a stack overflow, which produces the access violation error. See if any of these options can help you.

@KC-Cygnia
Copy link
Author

@KC-Cygnia Based on your class structure (which appears to be recursive) I'm going to go out on a limb and guess that you are encountering circular recursion which leads to a stack overflow, which produces the access violation error. See if any of these options can help you.

Hi,
Thanks, inline mapping and max depth helped as it was going in a loop of backward navigation, hence the error. May I suggest making maxdepth by default or handling the stack overflow? Hope this thread will help others with this issue.
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants