aybe/DearImGui

System.AccessViolationException in BeginPlot

gsuberland opened this issue · 4 comments

I created a new project in vscode and added the NuGet packages, and copied the demo code over to test the setup. However, I get the following on startup:

Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Repeat 2 times:
--------------------------------
   at DearImPlot.ImPlot+__Internal64.BeginPlot(System.String, IntPtr, DearImPlot.ImPlotFlags)
--------------------------------
   at DearImPlot.ImPlot.BeginPlot(System.String, System.Numerics.Vector2, DearImPlot.ImPlotFlags)
   at DearImPlot.ImPlot.BeginPlot(System.String)
   at TestApp.MyGameWindow.OnRenderFrame(OpenTK.Windowing.Common.FrameEventArgs)
   at OpenTK.Windowing.Desktop.GameWindow.DispatchRenderFrame()
   at OpenTK.Windowing.Desktop.GameWindow.Run()
   at TestApp.Program.Main(System.String[])

I can see from Process Hacker that the x86-64 glfw3.dll, imgui.dll, and implot.dll binaries (v1.8 / v0.14) are being loaded fine. These are the exact ones from the NuGet package.

aybe commented

Without code, it's hard to tell...

Off the top of my head:

https://github.com/aybe/DearImGui/blob/develop/SampleApplication.OpenTK/MyGameWindow.cs#L42

https://github.com/aybe/DearImGui/blob/develop/SampleApplication.OpenTK/MyGameWindow.cs#L44

These are a must to call else you typically get access denied.

It's a direct copy/paste of the sample app.

The fault occurs on this call:

if (ImPlot.BeginPlot("Sample plot"))

aybe commented

Push your repo somewhere.

I'm getting this also. It works fine if I clone this repository, build, then run the sample application. But when I replace the sample application's dependency on the DearImPlot project with a dependency on the DearImPlot NuGet package, I get the AccessViolationException.

When I enable native code debugging and attach source for implot.cpp (from the commit depended on by DearImGui: 15e494b, I get the following error at implot.cpp line 2332:

Exception thrown: read access violation.
Window was 0xFFFFFFFFFFFFFF64.