On Windows, an entity calling a script methods causes a crash

Issue #120 resolved
Carsten Fuchs created an issue

Observed in TestPatches, if the player walks into the invisible volume trigger, the trigger attempts to call the `OnTrigger` script functions, and crashes:

  1. !cpp void EntTriggerT::OnTrigger(BaseEntityT* Activator) { if (!IsActive) return;

GameWorld->GetScriptState().CallMethod(this, "OnTrigger", "G", Activator->Name.c_str()); }

The crash occurs because the Lua library is statically linked to the main executable `Cafu.exe` and the game DLL `DeathMatch.dll`.

The Lua library keeps internally a global state that is not shared across the EXE and the DLL, causing the crash.

The problem does not occur under Linux, where .so is properly bound to the executable and the global symbols uniquely resolved.

This is a variant of the problems that occur when the CRT is statically bound to exe's and dll's.

Comments (2)

  1. Carsten Fuchs reporter

    (In [572]) Game code, Engine core: No longer link the games/MODs dynamically as DLLs/SOs, but instead link them statically now.

    Dynamic linking is fraught with problems that are complemented by very little advantage: Check the diff of this revision for some of the details.

    Fixes #120.

  2. Log in to comment