Skip to content

Memory Access Violation on Il2CppSystem.Enum.ToString #211

@AndrewSav

Description

@AndrewSav

I was working on a mod for Blue Prince and I noticed that the process was crashing with memory access violation when calling ToString on instances of Il2CppSystem.Enum returned from the game. Not on a single one of them, on all that I tried.

I tried BepInEx and it did not crash under the same conditions. A MelonLoader discord member mentioned that the generation is the same in both, so that should not be happening. I compared the version Il2CppInterop used in both projects, and while they both are 1.4.6 they are different. MelonLoader uses 1.4.6-ci.579 whereas Bepinex uses 1.4.6-ci.426. Interestingly enough the 426 nuget package does not have the corresponding commit information, and the GitHub actions build makes it look like it came from a fork/branch since deleted.

None the less I was able to find a commit in the history that still worked, and bisected, until I found that the big 06cd048 commit is where it changed and stopped working.

When debugging, this is what I'm seeing when it crashes (on builds after the commit):

Image

And this is what it looks like when it does not crash (before the commit):

Image

I also noticed that type of Il2CppSystem.Enum changed from class to struct. Any idea what I'm doing wrong, and how to fix this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions