-
Notifications
You must be signed in to change notification settings - Fork 44
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
FGESEventListener.ReceiverWCO is not thread-safe #29
Comments
GES should only be called on game thread based on current design api. You're right however that the current implementation uses raw pointers a bit too liberally and thus can't properly detect when they are invalidated due to a garbage collection cycle. A refactor to smart pointers would likely alleviate this. Atm you can typically guarantee pointer sanity by balancing calls with Unbind All Events for Context, but this is less than ideal API imo. We should be able to auto-detect invalid receivers on emit and cleanup (which is in theory how it currently works, but raw pointers...). |
If you believe your changes above are all that are needed for the refactor, feel free to make a pull request, I'll run some tests and merge. |
Turn ReceiverWCO into a WeakPtr to avoid crashes #29
'Source/GlobalEventSystem/Public/GESHandlerDataTypes.h' defines
UObject* FGESMinimalEventListener.ReceiverWCO
, which points to UObjects in the scene, butListener.ReceiverWCO->IsValidLowLevelFast()
seems to fail regarding deleted objects.Spawning and deleting objects rapidly while triggering events leads to crashes:
In a first try I changed
ReceiverWCO
to a TWeakObjectPtr, which does not extend the lifetime of an object, but gets properly notified, when it gets deleted:With these changes I'm not able to reproduce the crashes, but I'm sure if it's really thread-safe or the way Epic intended. Here are some resources I found about this topic:
The text was updated successfully, but these errors were encountered: