» home
» bugs
» git

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000036 [litestep core] core minor always 2007-10-14 07:15 2009-03-05 15:16
Reporter ilmcuts View Status public  
Assigned To
Priority none Resolution open  
Status feedback   Product Version 0.24.7
Summary 0000036: Race condition if modules set error mode
Description In Module::_LoadDll() is first SetErrorMode to temporarily reset the process error mode to 0. After the following LoadLibrary call, the error mode is reset. This is a race condition if this happens on several threads.
Additional Information If thread A first calls SetErrorMode(0), then thread B does the same, thread B will receive '0' as the previous mode. If thread B reaches the second SetErrorMode line last, '0' will be set permanently.
Tags No tags attached.
Attached Files

- Relationships
related to 0000035feedback External DLLs cannot be placed in module directory 
related to 0000093feedback Remove 'threaded' module flag 

-  Notes
ilmcuts (manager)
2007-10-14 07:17

The fix is to serialize the SetErrorMode/LoadLibrary/SetErrorMode block, and to make sure that any initModuleEx only runs once all of the above blocks are done.
jugg (manager)
2008-08-18 10:46

The overhead to "fix" this isn't very likable. The fix would just be another patch added to the mess that is our threaded module implementation. We need to get rid of the threaded modules, not keep trying to patch the broken implementation.

Essentially the fix would consist of:

UINT uOldMode = SetErrorMode(0);


m_hInstance = LoadLibrary(m_tzLocation.c_str());


// Second, restore the old state

Where "_WaitOnAllModuleInit() would spin until any currently loading threaded modules finished their init routines.

Implementing _WaitOnAllModuleInit() would be slightly messy, but doable. I just don't see the worth in benefit vs effort for this edge case issue.

The reason you can't do your suggestion to serialize the calls is because of:

bool Module::Init(HWND hMainWindow, const std::string& sAppPath)
    ASSERT(NULL == m_hInstance);
    // delaying the LoadLibrary call until this point is necessary to make
    // grdtransparent work (it hooks LoadLibrary)
    if (_LoadDll())

- Issue History
Date Modified Username Field Change
2007-10-14 07:15 ilmcuts New Issue
2007-10-14 07:17 ilmcuts Note Added: 0000068
2007-10-14 07:17 ilmcuts Relationship added related to 0000035
2008-04-22 12:46 jugg Status @10@ => @30@
2008-08-18 10:46 jugg Note Added: 0000145
2009-01-16 16:21 ilmcuts Status @30@ => feedback
2009-03-05 15:16 ilmcuts Relationship added related to 0000093

Copyright © 2000 - 2009 Mantis Group
Powered by Mantis Bugtracker