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

AccessViolationException in ContactEventsManager.Flush #2578

Open
JeroMiya opened this issue Dec 24, 2024 · 3 comments
Open

AccessViolationException in ContactEventsManager.Flush #2578

JeroMiya opened this issue Dec 24, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@JeroMiya
Copy link

Release Type: Official Release

Version: 4.2.0.2282

Platform(s): Windows

Describe the bug
I'm not sure what triggers it exactly, but I can reproduce it in my project fairly consistently (see steps below).

To Reproduce
Steps to reproduce the behavior:

  1. Download the bepu-wip branch of my samples repo: https://github.com/JeroMiya/stride3d-samples/tree/bepu-wip
  2. Run the project, select Level1 to load the scene
  3. Wait in the start position for the white sphere to hit you
  4. Application crashes with this exception: AccessViolationException

Expected behavior
Either a better exception (if it's something wrong with my code) or no exception.

Screenshots
Image

Log and callstacks
See screenshot

@JeroMiya JeroMiya added the bug Something isn't working label Dec 24, 2024
@Eideren
Copy link
Collaborator

Eideren commented Dec 24, 2024

Might need need more checks in place higher up the stack when sending events.
Can you delay the Entity.Scene = null inside your void IContactEventHandler.OnStartedTouching to the next update to see if that is the issue ?

@JeroMiya
Copy link
Author

Might need need more checks in place higher up the stack when sending events. Can you delay the Entity.Scene = null inside your void IContactEventHandler.OnStartedTouching to the next update to see if that is the issue ?

Yep, after delaying the Entity.Scene = null to the next Update, it no longer crashes.

@Eideren
Copy link
Collaborator

Eideren commented Dec 24, 2024

Cool, thanks for checking, I can't fix this one until after the holidays though. If someone is interested it's in https://github.com/stride3d/stride/blob/master/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/Contacts/ContactEventsManager.cs
Have to check that removing the component while processing its events doesn't break bepu's unmanaged array and indexing we use in both HandleManifoldInner and Flush

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants