I’m encountering a crash in Chaos (UE 5.0.2-release) which I cannot solve or reproduce deterministically.
The crash occurs shortly (and randomly) after using a transient chaos field to put a geometry collection into a dynamic state, add an external cluster strain and a linear force.
Also, the crash usually occurs shortly after the second use of the fields shown below in a different spatial area (radius and center are different from the previous call).
The first time the fields are used, everything works as intended, the crash occurs only after the second or successive times the fields are applied.
UFieldSystemComponent* FieldSystem = ...;
// ...
FieldSystem->ApplyStayDynamicField(true, Center, Radius);
FieldSystem->ApplyStrainField(true, Center, Radius, ExternalStrain, 1);
FieldSystem->ApplyUniformVectorFalloffForce(true, Center, LinearForce, Radius, Magnitude);
The crash happens because the simulation is accessing an out of bounds index in &SolverBodies[ItemIndex].GetSolverBody()
in FSolverBodyContainer::FindOrAdd
.
Did anyone encounter this crash before or has any approach to prevent it from happening?
The backtrace is the following:
[Inlineframe] TArray<Chaos::FSolverBodyAdapter,TSizedDefaultAllocator<32>>::RangeCheck(int 5) Zeile 691 C++
[Inlineframe] TArray<Chaos::FSolverBodyAdapter,TSizedDefaultAllocator<32>>::operator[](int 5) Zeile 746 C++
> Chaos::FSolverBodyContainer::FindOrAdd(Chaos::FGenericParticleHandle {...}) Zeile 63 C++
[Inlineframe] Chaos::FPBDCollisionSolverAdapter::PreGatherInput(Chaos::FPBDCollisionConstraint &) Zeile 73 C++
Chaos::FPBDCollisionSolverContainer::PreAddConstraintSolver(Chaos::FPBDCollisionConstraint & {...}, Chaos::FSolverBodyContainer & {...}, int & 4) Zeile 425 C++
Chaos::TPBDConstraintColorRule<Chaos::FPBDCollisionConstraints>::GatherSolverInput(const double 0.025196399539709091, int) Zeile 338 C++
Chaos::FPBDRigidsEvolutionGBF::GatherSolverInput(double, int) Zeile 664 C++
Chaos::FPBDRigidsEvolutionGBF::AdvanceOneTimeStepImpl::__l63::<Lambdafunktion>(int 1) Zeile 468 C++
[Inlineframe] UE::Core::Private::Function::TFunctionRefBase<UE::Core::Private::Function::FFunctionRefStoragePolicy,void __cdecl(int)>::operator()(int 1) Zeile 676 C++
Chaos::PhysicsParallelFor::__l2::<Lambdafunktion>(int 1) Zeile 76 C++
[Inlineframe] UE::Core::Private::Function::TFunctionRefBase<UE::Core::Private::Function::FFunctionRefStoragePolicy,void __cdecl(int)>::operator()(int 1) Zeile 676 C++
[Inlineframe] ParallelForImpl::CallBody(const TFunctionRef<void __cdecl(int)> &) Zeile 180 C++
`ParallelForImpl::NewParallelForInternal<TFunctionRef<void __cdecl(int)>,<lambda_06f0d5d1c5fc9bccb0e7d1fd1e70ca42>,std::nullptr_t>'::`2'::FParallelExecutor::operator()(const bool false) Zeile 566 C++
[Inlineframe] LowLevelTasks::FTask::Init::__l2::<lambda_1bf4a01354d569cb2631b3617c09e35e>::operator()(const bool) Zeile 350 C++
[Inlineframe] Invoke(LowLevelTasks::FTask::Init::__l2::<lambda_1bf4a01354d569cb2631b3617c09e35e> &) Zeile 47 C++
[Inlineframe] LowLevelTasks::TTaskDelegate<void __cdecl(bool),48>::TTaskDelegateImpl<<lambda_1bf4a01354d569cb2631b3617c09e35e>,0>::Call(void *) Zeile 162 C++
LowLevelTasks::TTaskDelegate<void __cdecl(bool),48>::TTaskDelegateImpl<<lambda_1bf4a01354d569cb2631b3617c09e35e>,0>::CallAndMove(LowLevelTasks::TTaskDelegate<void __cdecl(bool),48> & {...}, void * 0x00007fff804e5c88, unsigned int 40, bool true) Zeile 171 C++
[Inlineframe] LowLevelTasks::TTaskDelegate<void __cdecl(bool),48>::CallAndMove(LowLevelTasks::TTaskDelegate<void __cdecl(bool),48> &) Zeile 308 C++
LowLevelTasks::FTask::ExecuteTask() Zeile 426 C++
LowLevelTasks::FScheduler::TryExecuteTaskFrom<&LowLevelTasks::TLocalQueueRegistry<1024>::TLocalQueue::DequeueGlobal,0>(LowLevelTasks::TLocalQueueRegistry<1024>::TLocalQueue * 0x0000024b0a186800, LowLevelTasks::TLocalQueueRegistry<1024>::FOutOfWork & {...}, bool, bool false) Zeile 280 C++
LowLevelTasks::FScheduler::WorkerMain(LowLevelTasks::FSleepEvent *, LowLevelTasks::TLocalQueueRegistry<1024>::TLocalQueue * 0x0000024b0a186800, unsigned int 1439, bool) Zeile 320 C++
[Inlineframe] LowLevelTasks::FScheduler::CreateWorker::__l2::<lambda_776551d1e343b6cb7eaf0e5521c77c81>::operator()() Zeile 86 C++
[Inlineframe] Invoke(LowLevelTasks::FScheduler::CreateWorker::__l2::<lambda_776551d1e343b6cb7eaf0e5521c77c81> &) Zeile 47 C++
UE::Core::Private::Function::TFunctionRefCaller<<lambda_776551d1e343b6cb7eaf0e5521c77c81>,void __cdecl(void)>::Call(void *) Zeile 549 C++
[Inlineframe] UE::Core::Private::Function::TFunctionRefBase<UE::Core::Private::Function::TFunctionStorage<1>,void __cdecl(void)>::operator()() Zeile 676 C++
FThreadImpl::Run() Zeile 69 C++
FRunnableThreadWin::Run() Zeile 146 C++
FRunnableThreadWin::GuardedRun() Zeile 68 C++
[Externer Code]