]> git.mxchange.org Git - flightgear.git/commit
#553: MP-model-loading related segfault
authorThorstenB <brehmt@gmail.com>
Sun, 8 Jan 2012 12:28:49 +0000 (13:28 +0100)
committerThorstenB <brehmt@gmail.com>
Sun, 8 Jan 2012 12:28:49 +0000 (13:28 +0100)
commit246feef85fedd548f2c198831d7d6e7e3be53e12
tree6ee7919909ef74e4cc46703bfdb16d168152854a
parent277ba10b39deb09ef7a9666325ba67e594986c80
#553: MP-model-loading related segfault
MP aircraft are loaded by a separate OSG thread (introduced after FG2.4.0).
The OSG thread also calls the "modelLoaded" callback. However, we mustn't
allow the OSG thread to call FGNasalModelData::modelLoaded directly:
FGNasalModelData isn't thread-safe. There are obvious issues (_callCount++;),
tricky issues like calling the Nasal _parser_ or creating hashes and
modifying the global Nasal namespace. It doesn't use locks to protect
against another thread executing a Nasal context or running garbage
collection. It also executes Nasal code itself (the model's "load" hook),
which we also cannot allow in a separate thread...
This patch returns all Nasal parts of MP-aircraft loading (parsing,
module creation, execution) to the main thread, while keeping the
multi-threaded OSG part (loading of MP-aircraft model files itself).
The same issue exists with scenery models (see other commit).

To summarize with 2 words: It s*cks... ;-)
src/AIModel/AIBase.cxx
src/AIModel/AIBase.hxx