#783 closed defect (fixed)
CMapGeneratorWorker isn't thread-safe
Reported by: | Philip Taylor | Owned by: | historic_bruno |
---|---|---|---|
Priority: | Must Have | Milestone: | Alpha 5 |
Component: | Core engine | Keywords: | |
Cc: | Jan Wassenberg | Patch: |
Description
CMapGeneratorWorker
runs in a non-main thread but calls fs_util::GetPathnames
and ScriptInterface::LoadGlobalScriptFile
which aren't thread-safe. (Those are the only problematic ones I see currently.)
This results in assertion failures in debug mode for me, and it could crash if e.g. hotloading occurs while the generator thread is running that function. (I've added some extra assertions now to make it complain more immediately.)
Either VFS needs to be made thread-safe (which sounds very hard), or the generator needs to avoid calling those functions except on the main thread. Maybe Initialize()
can read the script file into a string, and enumerate all maps/random/*/*.js
and read those into strings too (there won't be loads so it should be fast enough), and then the generator thread passes any requested files into ScriptInterface
as strings so it doesn't need to interact with the VFS again.
Change History (3)
comment:1 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 by , 13 years ago
Cc: | added |
---|
As discussed in the meeting, I don't see why VFS should be hard to make thread-safe. Wouldn't the proposed critical-section-in-each-VFS-routine solution safely handle this?
(In [9261]) CMapGeneratorWorker thread safety issue. Fixes #783. VFS access moved to main thread, where random map scripts are preloaded and stored prior to use by the worker thread. Adds LoadGlobalScript to ScriptInterface, for evaluating script content in the global scope.