Skip to content
This repository has been archived by the owner on Aug 22, 2018. It is now read-only.

Mysterious crashes #17

Open
kg opened this issue Aug 17, 2018 · 2 comments
Open

Mysterious crashes #17

kg opened this issue Aug 17, 2018 · 2 comments

Comments

@kg
Copy link

kg commented Aug 17, 2018

I'm using ImGuiCS like in your examples, but it crashes with an access violation the first time I call NewFrame. If I manually set custom alloc/free functions it invokes the alloc function a couple times instead of AVing, and then hangs for a while and my process exits with a random exit code.

Any idea what's gong on here? I'm baffled.

@kg
Copy link
Author

kg commented Aug 17, 2018

The SDL2 demo does work.

I tried doing this in my test app (an XNA game, compiled with vs2015):

            var io = ImGui.GetIO();
            var ptr = io.MemAlloc(16);

When I do this the debugger stops and the managed debugging assistants shout that the memalloc call unbalanced the stack.
Additional information: A call to PInvoke function 'ImGuiCS!ImGuiNET.MemAllocFn::Invoke' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

@kg
Copy link
Author

kg commented Aug 17, 2018

This appears to fix the MemAlloc invocation crash:

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public unsafe delegate void* MemAllocFn(void* sz);
    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public unsafe delegate void MemFreeFn(void* ptr);

Still explodes on my first call to NewFrame, though. Maybe the cdecl issue is related regardless?

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

No branches or pull requests

1 participant