You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public static void Main()
{
SDL_CreateWindow("Demo", 800, 600, 0);
var loop = true;
while (loop)
{
Console.WriteLine(loop); // True
SDL_PollEvent(out _);
Console.WriteLine(loop); // False
}
}
public static void Main()
{
SDL_CreateWindow("Demo", 800, 600, 0);
var a = true;
var b = true;
var c = true;
while (a || b || c)
{
Console.WriteLine($"before: a:{a}, b:{b}, c:{c}");
SDL_PollEvent(out _);
Console.WriteLine($"after: a:{a}, b:{b}, c:{c}");
}
}
Gascognya
changed the title
Incorrect PInvoke definition will implicitly modify local variable
Incorrect PInvoke definition will implicitly modify context local variable
Nov 23, 2024
out parameters are allocated on the stack and passed by reference. If its size is incorrect, native code accessing it will overwrite other memory on the stack, including return address.
The behavior is expected. Incorrect P/Invoke definition is unsafe and will corrupt things.
out parameters are allocated on the stack and passed by reference. If its size is incorrect, native code accessing it will overwrite other memory on the stack, including return address.
The behavior is expected. Incorrect P/Invoke definition is unsafe and will corrupt things.
Description
About libsdl-org/SDL C# bindings by PInvoke.
it's infinite loop, but broken.
Bug only occurs when the
out
parameter type definitions are inconsistent.The true definitions. it's large c union.
https://wiki.libsdl.org/SDL3/SDL_Event
Reproduction Steps
PInvokeSDL.zip
Expected behavior
infinite loop.
Actual behavior
infinite loop was broken.
Regression?
.net 8 and .net 9
Known Workarounds
no
Configuration
.net 8 and .net 9
windows 10
x64
Other information
No response
The text was updated successfully, but these errors were encountered: