microsoft / microsoft/mimalloc

program crashed on c# Pinvoke

Open
#306 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
13.4k
Forks
1.2k
Avg merge
4d 45m
Merged PRs (30d)
13

Description

i write a c++ dll , and this dll expose method for c# application to invoke,
after add mimalloc to the dll, the program will crash as next image
image

the c++ dll reletive code:
BYTE* data;
int test1(int a, int b) {

data = (BYTE*)mi_malloc(1920 * 1080);
return a + b;

}

the C# code
static class Program
{
[DllImport(@"Dll1.dll")]
public extern static int test1(int a, int b);

    /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main()
    {
        test1(1, 3);
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the C++ test1 entry point and the C# DllImport declaration shown in the issue, comparing the DLL behavior before and after adding mi_malloc. Reproduce the crash with the provided call, then capture the platform, build details, and stack trace; done means the crash is isolated with a minimal reproduction or its required interop conditions are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, csharp
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.