Hi.
I´ve found maybe a possible bug ( or uncommented bad feature ) in PhysX.
I´m using filterShader, callbacks and trigger shapes, on
Windows 7 64 Bit, VS 2012, with debug library, in debug mode.
Its unimportant to show code I guess, because this is a common error.
My PxBoxController touch more than 1 trigger shape ( which will be deleted on touch. )
( Collecting items as example )
I know that its not possible (and a very bad idea) to delete an actor while the simulation is running, so
I bufferd each call to onTrigger / onContact in a list. Outside the simulation, I am updating
this list and the object which contains the actor is marked as deletable,
and on the next call of my object manager delete it and any reference on it
- which is after the whole update from PhysX. (Fixed timestep , mostly 1 - 3 calls for updating PhysX )
My problem is that sometimes in the simulation phase Physx thinks that is a good idea to set
the trigger/contact data ( mostly otherShape, but everything can it be ) to a non valid pointer like
0xfeeefeee. This happens a lot when PxPairFlag::eNOTIFY_TOUCH_LOST was set. But often - there
are only invalid pointer - or values which cant be read or be validaded.
( The whole PxTriggerPair* data is sometimes invalid ! )
→
{ Maybe you can understand what happend when you think of a stack with 3 boxes.
Delete the box in the middle - now the boxes received the PxPairFlag::eNOTIFY_TOUCH_LOST
with the (almost) deleted middle box. Should work in on the first update, on the next, it crashed.
}
Its possible to check against these bit pattern, but there are more pattern like
0xabababab or 0xcdcdcdcd - even those which arent have a special context - but mostly readable like
0xcdcd200f or similar.
Of course, its possible to catch these invalid pointer when you trying to read them with
a try catch block, ( with enabled \Eha in VS 2012 )
But … using a try catch block on invalid pointer … is a very very bad idea I think.
I dont know why PhysX should tell me: Hey, there was a deleted actor, here was the valid adress -
but I changed it to non NULL so you think its probably still valid.
When I call mScene->flush() its non deterministic when it crashs - and I dont get any error message from
PhysX - only from VS 2012 which says that I try to read an invalid adress.
And yes, as I said, its possible to catch that interrupt, but … it should´nt be there!
So, why does PhysX give me invalid pointer instead of NULL pointer?