Skip to content

Commit ba5ade8

Browse files
authored
Fix potential recursive calls of WarpX constructor. (#6223)
WarpX's constructor may build objects that call WarpX::getInstance, which in turn build WarpX again if `m_instance` is nullptr. So we should assign `this` to `m_instance` at the beginning of the constructor to avoid the recursion.
1 parent ab947bd commit ba5ade8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Source/WarpX.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@ WarpX::Finalize()
320320

321321
WarpX::WarpX ()
322322
{
323+
m_instance = this; // This guarantees that GetInstance() can be
324+
// indirectly used in WarpX constructor.
325+
323326
warpx::initialization::initialize_warning_manager();
324327

325328
ReadParameters();

0 commit comments

Comments
 (0)