-
Notifications
You must be signed in to change notification settings - Fork 463
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
crashes when a Ragdoll points to a destroyed PhysicsSpace #1428
Comments
Unfortunately this is not something that can be fixed. The PhysicsSystem does not know about the existance of the Ragdoll so it cannot destroy it first. Ragdoll is a higher level concept that the physics system should not know about. In general Jolt tries to avoid links between objects as much as possible. This is one of the main reasons why you can do many things in a thread safe way. |
I understand. |
That's not a proper solution either. You can do:
This is quite common as a character may only need an active ragdoll during certain situations (e.g. hit responses), but you want to keep the ragdoll around because it's expensive to create. I don't think this is going to be the only case where destruction order matters and I would suggest looking into a more generic system to handle this. I took a quick look at jolt-jni:
My Java skills are pretty low so excuse me if my suggestions don't make sense. |
That makes sense.
I already track dependencies for C++ objects contained in other C++ objects, such as vectors. However, tracking doesn't help with this issue because it only prevents containers from being cleaned while their contents are strongly reachable. In this issue, neither the ragdoll nor the physics space is strongly reachable.
I don't know of any way to do this. I'll ask around. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
As I mentioned before, I'm creating Java bindings for JoltPhysics. Earlier this month I began experiencing various crashes:
After much experimentation, I've narrowed down the issue. I believe it relates to the order in which destructors for
RagDoll
andPhysicsSystem
are invoked.As you're probably aware, Java programmers aren't accustomed to thinking about object destruction. When using my Java bindings, C++ objects like physics systems and ragdoll references are allocated on the heap, and their destructors typically get invoked by an asynchronous automatic cleanup thread. In this scenario, the Java application cannot control the order in which those destructors are invoked. It's entirely possible for
PhysicsSystem::~PhysicsSystem
to be invoked beforeRagdoll::~Ragdoll
. In that case,~Ragdoll
accesses a destroyedPhysicsSystem
.This scenario is unlikely in C++ applications, where typical coding practices ensure destruction of all ragdolls prior to destruction of the physics system(s) they point to.
I ran an experiment where I disabled my cleanup thread so I could specify the destruction sequence. When the sequence was:
the application always completed successfully, but when the sequence was:
the application crashed every time at Jolt/Core/Array.h:455:
(inIdx < mSize)
.It ought to be possible to modify the
PhysicsSystem
class to keep track of all ragdolls that point to the system so that~PhysicsSystem
can invalidate those pointers. Or perhaps you can devise a better solution.The text was updated successfully, but these errors were encountered: