Although I do not know how to reproduce the crash, the change makes sense.
This is backported from gadmm's lyx-unstable tree
https://gitlab.com/gadmm/lyx-unstable/-/commit/
261ce4ea98d82625a07f0fcf85e40f9055d2db3b
// loop over children
for (auto const & p : d->children_positions) {
Buffer * child = const_cast<Buffer *>(p.first);
+ // This can happen when called during GUI operations
+ if (!theBufferList().isLoaded(child))
+ continue;
// No duplicates
ListOfBuffers::const_iterator bit = find(children.begin(), children.end(), child);
if (bit != children.end())