mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 08:35:20 +02:00
Emergeblocks: Fix occasional crash
Modification of the emergeblocks internal state was not protected by a lock, causing a race condition. This can be reproduced by repeatedly running emergeblocks for an already-generated section of the map (with multiple emerge threads).
This commit is contained in:
@@ -137,6 +137,10 @@ void LuaEmergeAreaCallback(v3s16 blockpos, EmergeAction action, void *param)
|
||||
assert(state->script != NULL);
|
||||
assert(state->refcount > 0);
|
||||
|
||||
// state must be protected by envlock
|
||||
Server *server = state->script->getServer();
|
||||
MutexAutoLock envlock(server->m_env_mutex);
|
||||
|
||||
state->refcount--;
|
||||
|
||||
state->script->on_emerge_area_completion(blockpos, action, state);
|
||||
|
Reference in New Issue
Block a user