Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispatch of KeyPress event throws a System.AccessViolationException #245

Open
AzuxirenLeadGuy opened this issue Apr 20, 2024 · 4 comments
Open

Comments

@AzuxirenLeadGuy
Copy link

Issue description

While running a RenderWindow instance, any KeyPress event results in throwing a System.AccessViolationException.

How to reproduce

Run the example project in example/window, and press any key

Expected behaviour

The key is processed by the event successfully

Actual behaviour

An uncaught exception interrupts the program, with the following message on the console.

Press ESC key to close window
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at SFML.Window.WindowBase.CallEventHandler(SFML.Window.Event)
   at SFML.Window.WindowBase.DispatchEvents()
   at window_core.SimpleWindow.Run()
   at window_core.Program.Main(System.String[])
@uwaaya
Copy link

uwaaya commented May 11, 2024

this is a serious heisenbug in SFML.Net. it cant usually be replicated while debugging but it appears in release builds.
the new ScanCode field of CSFML 2.6 wasnt accounted for in Event or KeyEvent, and inconsequentially KeyEventArgs. the total size of CSFML events is now 28 bytes. adding the field to KeyEvent and updating the size of the Event struct fixes this crash.

@uwaaya
Copy link

uwaaya commented May 11, 2024

its also worth mentioning that this same bug may cause KeyEvent to not report correct values (i have not tested this), so fixing it will kill two birds with one stone

@eXpl0it3r
Copy link
Member

It might be recommended to stick to CSFML 2.5.2 until SFML.Net has been updated for 2.6

@uwaaya
Copy link

uwaaya commented May 21, 2024

if its any consolation, this is the only problem with SFML.NET which we could find.
we patched this bug in our internal fork of SFML.NET (currently 321101d) with CSFML 2.6, and have been essentially field testing it for over a week. we have not discovered any further problems from upstream besides this one.

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

No branches or pull requests

3 participants