Hello,
I use NetBSD 10.1 and tried first to install codeblocks 20.03 binary package. Starting codeblocks freezes on libcompiler.so plugin, it outputs minimally one (or more) "Added compiler <COMPILER_NAME>" and stopped with splashscreen. When I removed libcompiler.so from plugins directory then IDE can successfully start.
After day of fighting with codeblocks building I successfully built it from source code with all plugins, but result is the same.
How to diagnose this problem ?
I looked into plugins/compilergcc how to restrict list of supported compilers to support only GNU GCC compiler, because minimally it is displayed on every start.
But I am not able to orientate in source code how to restrict number of compilers or how to see some debug messages for diagnose.
What should I try ?
Peter
You can open a console and execute C::B from there, adding --verbose and --debug-log if needed.
You have compiled C::B, so you have the non-stripped executable. Execute it through GDB, when the program hangs use Ctrl-C to pause it, "where" to see the current execution point and then "continue" (if needed).
codeblocks start outputs:
...
Added compiler "GNU GCC Compiler"
[New process 1532]
[LWP 1271 of process 1532 exited]
and gdb shows:
(gdb) file /usr/local/lib/libcodeblocks.so.0
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Load new symbol table from "/usr/local/lib/libcodeblocks.so.0"? (y or n) y
Reading symbols from /usr/local/lib/libcodeblocks.so.0...
(No debugging symbols found in /usr/local/lib/libcodeblocks.so.0)
(gdb) bt
#0 0x00007156dcca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
#1 0x00007156dde0b1ed in pthread_cond_timedwait (cond=0x7156dd5d4a88, mutex=0x7156dd5df140, abstime=0x0) at /usr/src/lib/libpthread/pthread_cond.c:170
#2 0x00007156de399c88 in wxConditionInternal::Wait() () from /usr/pkg/lib/libwx_baseu-3.0.so.0
#3 0x00007156de39f92c in wxSemaphoreInternal::Wait() () from /usr/pkg/lib/libwx_baseu-3.0.so.0
#4 0x00007156e1bacbf9 in cbThreadPool::cbWorkerThread::Entry() () from /usr/local/lib/libcodeblocks.so.0
#5 0x00007156de3a5d65 in wxThread::CallEntry() () from /usr/pkg/lib/libwx_baseu-3.0.so.0
#6 0x00007156de3a5f63 in wxThreadInternal::PthreadStart(wxThread*) () from /usr/pkg/lib/libwx_baseu-3.0.so.0
#7 0x00007156dde0c89f in pthread__create_tramp (cookie=0x7156de07b400) at /usr/src/lib/libpthread/pthread.c:595
#8 0x00007156dcc930e0 in ?? () from /usr/lib/libc.so.12
#9 0x0000000000000000 in ?? ()
(gdb) add-symbol-file /home/programmer/.codeblocks-20.03/src/sdk/.libs/libcodeblocks.so
add symbol table from file "/home/programmer/.codeblocks-20.03/src/sdk/.libs/libcodeblocks.so"
(y or n) y
/home/programmer/.codeblocks-20.03/src/sdk/.libs/libcodeblocks.so: No such file or directory.
(gdb) add-symbol-file /home/programmer/codebl/codeblocks-20.03/src/sdk/.libs/libcodeblocks.so
add symbol table from file "/home/programmer/codebl/codeblocks-20.03/src/sdk/.libs/libcodeblocks.so"
(y or n) y
Reading symbols from /home/programmer/codebl/codeblocks-20.03/src/sdk/.libs/libcodeblocks.so...
(No debugging symbols found in /home/programmer/codebl/codeblocks-20.03/src/sdk/.libs/libcodeblocks.so)
(gdb)
So by verbose output maybe some process was started and probably unexpectedly terminated and function cbThreadPool::cbWorkerThread::Entry() in source file cbthreadpool.cpp #182 waits for it (or for something other)... I am not sure.
What should I try ?
I rebuild codeblocks and tried again. It freezes again in the same place like I posted above.
codeblocks starting output:
Added compiler "GNU GCC Compiler"
[New process 20719]
[LWP 27145 of process 20719 exited]
and When I tried display processes:
...
programmer 1728 0.0 0.0 20628 2200 pts/0 Is 9:01AM 0:00.30 | | |-- sh
root 20002 0.0 0.0 20584 2120 pts/0 I 6:32PM 0:00.25 | | | `-- sh
root 915 39.6 1.6 274616 200900 pts/0 Sl 6:33PM 0:13.80 | | | `-- gdb codeblocks
root 20719 6.8 0.7 519668 93064 pts/0 SXl+ 6:33PM 0:04.66 | | | `-- /usr/local/bin/codeblocks
root 13499 0.0 0.0 0 0 pts/0 Z+ - 0:00.00 | | | `-- (gcc)
...
Can anybody explain what happens here ?
What means [LWP 27145 of process 20719 exited] and how can help it ? Is it any problem in kernel ?
Why is (gcc) under codeblocks process like it's child ?
I found that src/src/prefix.cpp uses conditional compilation by #define BR_PTHREADS
I tried to set it to 0, it does not help.
When codeblocks enters into freeze state described above and after it I reboot then it starts automatically after login and (of course) freezes again.
Does anybody know what is this feature for ?
Moreover I am not able to find where is command for it's automatic starting.
...
root 0 0.0 0.7 0 89180 ? DKl 4:56PM 0:04.69 [system]
root 1 0.0 0.0 19972 1700 ? Is 4:56PM 0:00.01 - init
programmer 1073 1.5 0.7 526472 89016 ttyE0 Il 3:58PM 0:04.43 |-- codeblocks
programmer 1357 0.0 0.0 0 0 ttyE0 Z - 0:00.00 | `-- (gcc)
root 335 0.0 0.0 23200 1680 ? Ss 3:56PM 0:00.01 |-- /usr/sbin/rpcbind -l
dbus 802 0.0 0.0 30000 2468 ? Is 3:56PM 0:00.04 |-- /usr/pkg/bin/dbus-daemon --system --fork
...
more diagnostic info:
I rebuild libcompiler.so with debug info and investigated another thread's stacks , not only thread displayed
by "where" command.
It is weird, that two threads try to load the same MINGW compiler and two has the same stack, why OnInit() is called in two separate threads ?
(gdb) info threads
Id Target Id Frame
* 1 LWP 2893 of process 2893 "" 0x0000739919c4729a in _sys___select50 () from /usr/lib/libc.so.12
2 LWP 3308 of process 2893 "[pango] fontcon" 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
3 LWP 3396 of process 2893 "pool-spawner" 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
4 LWP 3631 of process 2893 "gmain" 0x0000739919c4745a in poll () from /usr/lib/libc.so.12
6 LWP 3307 of process 2893 "" 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
7 LWP 1622 of process 2893 "" 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
8 LWP 5002 of process 2893 "" 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
9 LWP 4998 of process 2893 "" 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
10 LWP 2893 of process 2893 "" 0x0000739919c4729a in _sys___select50 () from /usr/lib/libc.so.12
11 process 2893 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
(gdb) bt
#0 0x0000739919c4729a in _sys___select50 () from /usr/lib/libc.so.12
#1 0x000073991ae086f0 in __select50 (nfds=<optimized out>, readfds=<optimized out>, writefds=<optimized out>, exceptfds=<optimized out>,
timeout=<optimized out>) at /usr/src/lib/libpthread/pthread_cancelstub.c:605
#2 0x000073991b38810f in wxSelectDispatcher::DoSelect(wxSelectSets&, int) const () from /usr/pkg/lib/libwx_baseu-3.0.so.0
#3 0x000073991b3888f1 in wxSelectDispatcher::Dispatch(int) () from /usr/pkg/lib/libwx_baseu-3.0.so.0
#4 0x000073991b3afaf8 in wxExecute(char**, int, wxProcess*, wxExecuteEnv const*) () from /usr/pkg/lib/libwx_baseu-3.0.so.0
#5 0x000073991b3b1727 in wxExecute(wxString const&, int, wxProcess*, wxExecuteEnv const*) () from /usr/pkg/lib/libwx_baseu-3.0.so.0
#6 0x000073991b3c42e0 in ?? () from /usr/pkg/lib/libwx_baseu-3.0.so.0
#7 0x000073991ebbd252 in Compiler::EvalXMLCondition(wxXmlNode const*) () from /usr/local/lib/libcodeblocks.so.0
#8 0x000073991ebc27ef in Compiler::LoadDefaultOptions(wxString const&, int) () from /usr/local/lib/libcodeblocks.so.0
#9 0x000073991ebc47cc in Compiler::LoadDefaultOptions(wxString const&, int) () from /usr/local/lib/libcodeblocks.so.0
#10 0x000073991ebc55e3 in Compiler::Reset() () from /usr/local/lib/libcodeblocks.so.0
#11 0x0000739902aa6241 in CompilerMINGW::CompilerMINGW (this=0x739918077c00, name=..., ID=...) at compilerMINGW.cpp:35
#12 0x0000739902a88f2f in CompilerGCC::DoRegisterCompilers (this=0x73991a460000) at compilergcc.cpp:887
#13 0x0000739902a844cf in CompilerGCC::OnAttach (this=0x73991a460000) at compilergcc.cpp:355
#14 0x000073991eb98bbd in cbPlugin::Attach() () from /usr/local/lib/libcodeblocks.so.0
#15 0x000073991ec97c6f in PluginManager::AttachPlugin(cbPlugin*, bool) () from /usr/local/lib/libcodeblocks.so.0
#16 0x000073991ec9b976 in PluginManager::LoadAllPlugins() () from /usr/local/lib/libcodeblocks.so.0
#17 0x00000000004ecebe in MainFrame::ScanForPlugins() ()
#18 0x00000000004f012e in MainFrame::MainFrame(wxWindow*) ()
#19 0x0000000000464861 in CodeBlocksApp::InitFrame() ()
#20 0x000000000046a89a in CodeBlocksApp::OnInit() ()
#21 0x000073991b303e95 in wxEntry(int&, wchar_t**) () from /usr/pkg/lib/libwx_baseu-3.0.so.0
#22 0x000000000055f764 in main ()
(gdb) thr 10
[Switching to thread 10 (LWP 2893 of process 2893)]
#0 0x0000739919c4729a in _sys___select50 () from /usr/lib/libc.so.12
(gdb) info threads
Id Target Id Frame
1 LWP 2893 of process 2893 "" 0x0000739919c4729a in _sys___select50 () from /usr/lib/libc.so.12
2 LWP 3308 of process 2893 "[pango] fontcon" 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
3 LWP 3396 of process 2893 "pool-spawner" 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
4 LWP 3631 of process 2893 "gmain" 0x0000739919c4745a in poll () from /usr/lib/libc.so.12
6 LWP 3307 of process 2893 "" 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
7 LWP 1622 of process 2893 "" 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
8 LWP 5002 of process 2893 "" 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
9 LWP 4998 of process 2893 "" 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
* 10 LWP 2893 of process 2893 "" 0x0000739919c4729a in _sys___select50 () from /usr/lib/libc.so.12
11 process 2893 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
(gdb) bt
#0 0x0000739919c4729a in _sys___select50 () from /usr/lib/libc.so.12
#1 0x000073991ae086f0 in __select50 (nfds=<optimized out>, readfds=<optimized out>, writefds=<optimized out>, exceptfds=<optimized out>,
timeout=<optimized out>) at /usr/src/lib/libpthread/pthread_cancelstub.c:605
#2 0x000073991b38810f in wxSelectDispatcher::DoSelect(wxSelectSets&, int) const () from /usr/pkg/lib/libwx_baseu-3.0.so.0
#3 0x000073991b3888f1 in wxSelectDispatcher::Dispatch(int) () from /usr/pkg/lib/libwx_baseu-3.0.so.0
#4 0x000073991b3afaf8 in wxExecute(char**, int, wxProcess*, wxExecuteEnv const*) () from /usr/pkg/lib/libwx_baseu-3.0.so.0
#5 0x000073991b3b1727 in wxExecute(wxString const&, int, wxProcess*, wxExecuteEnv const*) () from /usr/pkg/lib/libwx_baseu-3.0.so.0
#6 0x000073991b3c42e0 in ?? () from /usr/pkg/lib/libwx_baseu-3.0.so.0
#7 0x000073991ebbd252 in Compiler::EvalXMLCondition(wxXmlNode const*) () from /usr/local/lib/libcodeblocks.so.0
#8 0x000073991ebc27ef in Compiler::LoadDefaultOptions(wxString const&, int) () from /usr/local/lib/libcodeblocks.so.0
#9 0x000073991ebc47cc in Compiler::LoadDefaultOptions(wxString const&, int) () from /usr/local/lib/libcodeblocks.so.0
#10 0x000073991ebc55e3 in Compiler::Reset() () from /usr/local/lib/libcodeblocks.so.0
#11 0x0000739902aa6241 in CompilerMINGW::CompilerMINGW (this=0x739918077c00, name=..., ID=...) at compilerMINGW.cpp:35
#12 0x0000739902a88f2f in CompilerGCC::DoRegisterCompilers (this=0x73991a460000) at compilergcc.cpp:887
#13 0x0000739902a844cf in CompilerGCC::OnAttach (this=0x73991a460000) at compilergcc.cpp:355
#14 0x000073991eb98bbd in cbPlugin::Attach() () from /usr/local/lib/libcodeblocks.so.0
#15 0x000073991ec97c6f in PluginManager::AttachPlugin(cbPlugin*, bool) () from /usr/local/lib/libcodeblocks.so.0
#16 0x000073991ec9b976 in PluginManager::LoadAllPlugins() () from /usr/local/lib/libcodeblocks.so.0
#17 0x00000000004ecebe in MainFrame::ScanForPlugins() ()
#18 0x00000000004f012e in MainFrame::MainFrame(wxWindow*) ()
#19 0x0000000000464861 in CodeBlocksApp::InitFrame() ()
#20 0x000000000046a89a in CodeBlocksApp::OnInit() ()
#21 0x000073991b303e95 in wxEntry(int&, wchar_t**) () from /usr/pkg/lib/libwx_baseu-3.0.so.0
#22 0x000000000055f764 in main ()
(gdb) info threads
Id Target Id Frame
1 LWP 2893 of process 2893 "" 0x0000739919c4729a in _sys___select50 () from /usr/lib/libc.so.12
2 LWP 3308 of process 2893 "[pango] fontcon" 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
3 LWP 3396 of process 2893 "pool-spawner" 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
4 LWP 3631 of process 2893 "gmain" 0x0000739919c4745a in poll () from /usr/lib/libc.so.12
6 LWP 3307 of process 2893 "" 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
7 LWP 1622 of process 2893 "" 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
8 LWP 5002 of process 2893 "" 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
9 LWP 4998 of process 2893 "" 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
* 10 LWP 2893 of process 2893 "" 0x0000739919c4729a in _sys___select50 () from /usr/lib/libc.so.12
11 process 2893 0x0000739919ca8e7a in ___lwp_park60 () from /usr/lib/libc.so.12
(gdb) thr 11
Thread ID 11 has terminated.
(gdb)
I debugged compiler.cpp , function member Compiler::EvalXMLCondition() to see what is passed to wxExecute().
See attached screens from debugger.
First it sets flag by wx version. wx-config outputs that I have installed 3.0.5.
in compiler.cpp code is comment:
#if wxCHECK_VERSION(3, 0, 0)
// Stop event-loop while wxExecute runs, to avoid a deadlock on startup,
// that occurs from time to time on wx3
flags |= wxEXEC_NOEVENTS;
#else
flags |= wxEXEC_NODISABLE;
#endif
wxLogNull logNo; // do not warn if execution fails
ret = wxExecute(GetStringFromArray(cmd, wxT(" "), false), cmd, flags);
I am attaching two screens from debugging and my code is going through first condition. Even It freezes when called wxExecute().
I tried also to comment first condition to force WxEXEC_NODISABLE. Then several threads enters into wait state, but codeblocks also freezes.
Se attached screens.
Any ideas ?
Upgrade to wxWidgets 3.2 or find the fix done in 3.1.2 and back port it.
Tim S.
Quote
3.1.2: (released 2018-12-10)
----------------------------
All:
- Add wxLZMA{Input,Output}Stream classes using external liblzma.
- Make wxList and wxVector iterators conform to input iterator requirements.
- Fix MT-safety problem when reading and writing from wxSocket (jkubalik).
- Fix build issues under HaikuOS (mill-j).
- Fix problem with wx-config installation and use under NetBSD (wiz).
- Avoid spurious errors on thread creation under NetBSD.
- Improve high DPI support in wxAui (Simon Rozman).
- Fix a bug with parsing time zones in wxDateTime::ParseFormat() (evileye).
- Update all 3rd party libraries to their latest versions (Maarten Bent).
I built wxWidgets 3.1.2 from sources and the rebuilt codeblocks. Result is the same. I see two threads registering MINGW compiler and another threads waiting. See attached pictures. After it I rebuilt it with wxExecute() parameter flag = wxEXEC_NODISABLE, it does not help.
Is not problem that codeblocks tries to register the same compiler in two different threads instead of finding bug in wxGTK ?
That was not one of the two things I suggested.
Edit: If I had this problem, I would work to duplicate it using an wxWidgets sample and then communicate with either the NetBSD team or wxWidgets team on how to fix it. But, building the newest wxWidgets 3.2.x version or the git master branch would be another way to see if that fixes it. AS I already suggested building wxWidgets 3.2 would be my first thing to try. But, if that failed I would try to build the closest wxWidgets sample likely to have the problem and report it to the wxWidgets team and see what they say. But, the wx sample(s) might all work great. It has been close to a decade since I last built Code::Blocks under an BSD distro; no other ideas to suggest.
Tim S.
Thank you Tim for navigating.
I have codeblocks built from last sources with built of wxWidgets-3.2.5 from sources.
Problem with starting compiler plugin is still here and I found that probably it is crashing of child's forked process after called fork() inside of wxWidgets for some specific reason relating to NetBSD os. fork() is called inside of wxExecute() .
Passed command line from codeblocks into wxExecute() sees ok, it tries to call "gcc -dumpversion". But Maybe on NetBSD is using of fork() problem in multithreaded application.
Or it can be some problem with thread synchronization objects.
I must take back my question about registering compiler in two separate threads when investigated with "info thread" under gdb. Now I am seeing that both threads has the same LWP, so it is probably some gdb's way of outputting forked process.
QuotewxExecute() tries to call "gcc -dumpversion". Maybe on NetBSD is needed different flags
Open the console and do the call yourself, gcc should return the version as numbers separated by dots. Try also -dumpfullversion, just in case.
Yes, it is functional when I do it manually in console
/home/programmer/wxWidgets-3.2.5$ gcc -dumpversion
10.5.0
/home/programmer/wxWidgets-3.2.5$ gcc -dumpfullversion
10.5.0
Do you have the shell configured correctly (in Setting -> Environment settings -> General settings -> Shell to run commands in)?.
The default for Mac was not correct, NetBSD may be similar. The default is
/bin/sh -c
Miguel,
Watch the source code for CB used by Beesdeckar and ensure that it is the latest as the other thread has "When I checkout from current branch then build successfully finished.", which could mean anything.
Quote from: Miguel Gimenez on January 22, 2025, 03:49:18 PM
Do you have the shell configured correctly (in Setting -> Environment settings -> General settings -> Shell to run commands in)?.
When I remove libcompiler from plugins and codeblocks then successfully starts I am seeing correct setting: "/bin/sh -c"
But I think it has nothing with my problem. Above problem is relating to registering compilers in start phase of codeblocks (libcompiler.so).
Yesterday I tried to debug it more deeply wxExecute() and found that it is probably problem with using fork() in multithreaded application on NetBSD.
I am trying to discuss with wxWidgets's guys about it in their forum:
https://forums.wxwidgets.org/viewtopic.php?t=51840
Quote
Watch the source code for CB used by Beesdeckar and ensure that it is the latest as the other thread
Be sure that I am working with latest branch from svn. First time I thought that 20.03 is something new.
Some new info: see link in wxWidgets forum, I repeat problem with help of their sample "exec". But it reproduces only from time to time.