During startup, compiler.cpp iterates through all known compilers testing for availability with a call to wxExecute(). This will occasionally hang waiting on a dispatched select(2) -- and this will occur at different points in the iteration through the list of compilers, so there is some race condition occurring that affects behavior of wxWidgets, glib, or perhaps system call functionality.
OS: OpenBSD, 7.1-current.
wxWidgets: 3.0.5.1
glib2: 2.70.5
If I switch the wxExecute flags wxEXEC_SYNC and wxEXEC_NOEVENTS to wxEXEC_ASYNC, the race condition does not occur. All compiler tests complete and C::B starts up without problems.
While this is an apparent working circumvention, I'm concerned that it may have a detrimental impact that I do not foresee, and would appreciate a review. I could use some advice as to whether to keep this circumvention in place or not, and perhaps, how I could dig down deeper to determine the root cause of the hang on select().
Thank you in advance for any insights or guidance you may have.
---
This circumvention was tested with svn 12783.
Patch:
Index: src/sdk/compiler.cpp
--- src/sdk/compiler.cpp.orig
+++ src/sdk/compiler.cpp
@@ -1600,10 +1600,7 @@ long Compiler::Execute(const wxString& cmd, wxArrayStr
long Compiler::Execute(const wxString& cmd, wxArrayString& output)
{
wxLogNull logNo; // do not warn if execution fails
- int flags = wxEXEC_SYNC;
- // Stop event-loop while wxExecute runs, to avoid a deadlock on startup,
- // that occurs from time to time on wx3
- flags |= wxEXEC_NOEVENTS;
+ int flags = wxEXEC_ASYNC;
return wxExecute(cmd, output, flags);
}
#endif // __WXMSW__
Hanging thread backtrace:
Thread 1 (thread 417033):
#0 _thread_sys_select () at /tmp/-:3
#1 0x00000bc712e4c33e in _libc_select_cancel (nfds=20, readfds=0x7f7ffffed820, writefds=0x7f7ffffed8a0, exceptfds=0xbc712e469aa <_thread_sys_select+10>, timeout=0x0) at /usr/src/lib/libc/sys/w_select.c:28
#2 0x00000bc79c98e6a9 in wxSelectSets::Select (this=<optimized out>, nfds=20, tv=0x0) at ./src/common/selectdispatcher.cpp:109
#3 wxSelectDispatcher::DoSelect (this=0x7f7ffffedbe0, sets=..., timeout=<optimized out>) at ./src/common/selectdispatcher.cpp:230
#4 wxSelectDispatcher::Dispatch (this=0x7f7ffffedbe0, timeout=<optimized out>) at ./src/common/selectdispatcher.cpp:249
#5 0x00000bc79c9a72d4 in (anonymous namespace)::BlockUntilChildExit (execData=...) at ./src/unix/utilsunx.cpp:554
#6 wxExecute (argv=<optimized out>, flags=<optimized out>, process=<optimized out>, env=<optimized out>) at ./src/unix/utilsunx.cpp:858
#7 0x00000bc79c9a637b in wxExecute (command=..., flags=17, process=0xbc6d4753400, env=0x0) at ./src/unix/utilsunx.cpp:475
#8 0x00000bc79c9c2e02 in wxDoExecuteWithCapture (command=..., output=..., error=0x0, flags=<optimized out>, env=0x0) at ./src/common/utilscmn.cpp:687
#9 0x00000bc7902a6b37 in Compiler::Execute (this=<optimized out>, cmd=..., output=...) at compiler.cpp:1607
#10 0x00000bc7902a4f1e in Compiler::EvalXMLCondition (this=0xbc6d4777380, node=0xbc76db86100) at compiler.cpp:1344
#11 0x00000bc790294a4f in Compiler::LoadDefaultOptions (this=0xbc6d4777380, name=..., recursion=1) at compiler.cpp:864
#12 0x00000bc7902949ae in Compiler::LoadDefaultOptions (this=0xbc6d4777380, name=..., recursion=0) at compiler.cpp:1072
#13 0x00000bc7902935dd in Compiler::Reset (this=0xbc6d4777380) at compiler.cpp:163
#14 0x00000bc76db293e9 in CompilerXML::CompilerXML (this=0xbc6d4777380, name=..., ID=..., file=...) at compilerXML.cpp:24
#15 0x00000bc76dac113f in CompilerGCC::DoRegisterCompilers (this=<optimized out>) at compilergcc.cpp:994
#16 0x00000bc76dabec9e in CompilerGCC::OnAttach (this=0xbc711a17c00) at compilergcc.cpp:361
#17 0x00000bc79025d97b in cbPlugin::Attach (this=0xbc711a17c00) at cbplugin.cpp:73
#18 0x00000bc7903734bf in PluginManager::AttachPlugin (plugin=0xbc711a17c00, ignoreSafeMode=<error reading variable: Cannot access memory at address 0x0>, this=<optimized out>) at pluginmanager.cpp:197
#19 PluginManager::LoadAllPlugins (this=<optimized out>) at pluginmanager.cpp:1119
#20 0x00000bc4b0ab9b09 in MainFrame::ScanForPlugins (this=0xbc6d198a7b0) at main.cpp:1496
#21 0x00000bc4b0ab4d1a in MainFrame::MainFrame (this=0xbc6d198a7b0, parent=<optimized out>) at main.cpp:794
#22 0x00000bc4b0a2543c in CodeBlocksApp::InitFrame (this=0xbc70c5e7800) at app.cpp:494
#23 CodeBlocksApp::OnInit (this=0xbc70c5e7800) at app.cpp:717
#24 0x00000bc79c90b06d in wxEntry (argc=<optimized out>, argv=<optimized out>) at ./src/common/init.cpp:490
#25 0x00000bc4b0a2267e in main (argc=1, argv=0x7f7ffffed820) at app.cpp:327
Edit: clarity, release levels