Game Locked in Infinite Loop

This happened with two games. Game play freezes and CPU usage kicks up. Can still chat and pan camera, as UI isn't frozen, but SIM is. I suspect the SIM is stuck in an endless loop.

Both logs end with this:
debug: Loading module: /lua/ui/dialogs/keybindings.lua
debug: -> Loading module: /lua/keymap/properkeynames.lua
debug: -> Loading module: /lua/keymap/keynames.lua
debug: -> Loading module: /lua/keymap/keycategories.lua

Replays are:
#21155827
#21155679

I recently added some new scripts to AI Wave Survival, so I don't know if the mod is causing the loop or something else. (The new scripts create an invisible unit randomly around the map, then tests if the unit can path to players. If true, the position is saved to a list and the unit destroyed. The list is used to create Rift Orbs, which can spawn in units from that location. The script runs once every second and stops after it has found 400 locations.)

I've been unable to recreate the issue in testing with bots. And the mod worked fine with the new scripts when playing with people the other night. Since I haven't been able to re-create the issue with bots, I am having trouble narrowing down what could have caused the crashes.

Any help appreciated.

I believe I have found the problem.

Looks like the function GetTerrainHeight(posX, posZ) was calling a value it didn't have access to, which must have been causing the infinite loop. Error wasn't getting written to the log in prior playthroughs, so hopefully that is it.