Fatal Crash when loading a save with pending Lua Object:teleport() actions

Issue Description

OpenMW crashes during save loading when a global Lua script continuously moves an object using Object:teleport().

The issue was initially encountered with spell projectiles, then reproduced independently using one ordinary gold object, without WandForge or the spell framework loaded. The reproducer requests one teleport per update, including paused updates. Its onLoad handler disables movement and does not spawn or teleport anything.

Expected: Loading completes without executing movement against invalid state from the previous world.

Actual: Loading crashes with a native access violation. The instrumented reproduction failed at openmw.exe+0x171c54, exception 0xc0000005. Native stack analysis follows:

LuaManager::applyDelayedActions() → DelayedAction::apply() → non-player teleport callback → World::moveObject() → CellStore loading

Suspected cause

During paused updates, simulation time does not advance, so the marker’s calculated destination remains unchanged. However, the script continues calling Object:teleport(), which queues new actions even for that unchanged destination.

The teleport action captures a raw destination CellStore*. Loading destroys the previous world, invalidating that pointer. If the action survives cleanup and subsequently executes, it can access the destroyed cell. Clearing pending Lua actions during LuaManager::clear() prevents the observed reproduction from crashing.

Steps to Reproduce

Using the OpenMW-Queued-Move-test.zip package:

  1. Use the unpatched engine. Extract the package and run Run-Test.cmd, supplying your OpenMW.exe path and Morrowind Data Folder path.
  2. The launcher starts a fresh isolated game in Balmora, Guild of Mages.
  3. Wait for READY, then press F6 to select Test A and start the gold marker moving.
  4. Wait approximately three seconds.
  5. Save through the ordinary game menu, then load that save while movement remains enabled. Do not press F7.
  6. Observe the crash during loading.

For comparison, launch a fresh session and repeat using F8 for Test B. This mode stops future movement requests inside onSave; the recorded B attempt loaded successfully.

“Movement” refers to the marker. The player can remain stationary, and save names are arbitrary.

System Information

  • OpenMW Version: 0.51.0 RC1, revision b850d13e58ca3ed4b7a5cd52d6e74e3282d6e902
  • Operating System & Version: Windows, version 25H2, build 26200.9445
  • GPU: NVIDIA GeForce RTX 4080 SUPER; driver 610.88
  • Morrowind Version: Steam
  • Language: English
  • Addons: Tribunal and Bloodmoon installed; their BSA archives were available, but their ESM files were not enabled in the reproduction.

Mods

  • Are you using mods? Yes—only the standalone diagnostic Lua addon. Loaded content was builtin.omwscripts, Morrowind.esm, and movement_trace_ab.omwscripts.
  • Are you using any shader mods? No.
  • Does it happen in a clean vanilla install? Untested without the diagnostic addon. It reproduces with base-game content plus this isolated Lua reproducer, without WandForge, SFP, or other third-party mods.

Logs and Settings

openmw.log

settings.cfg

Edited by slowchu