Could you test for an empty lambda in LambdaCallback::modalStateFinished() ? (in Juce_ModalComponentManager.cpp, line 284)
void modalStateFinished (int result) override { if (function != nullptr) function (result); }
Otherwise a code like that will crash :
popupMenu.showMenuAsync (PopupMenu::Options(), function);
when called with an empty std::function<void(int)> function;
(when the user clicks a menu item)