Author Topic: CC makes C::B hang in ExpandBackticks  (Read 65514 times)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: CC makes C::B hang in ExpandBackticks
« Reply #45 on: January 06, 2013, 01:00:25 am »
Should I commit this last patch? What should be the commit message?

p.s. I tried it and it worked, but I've not tested it much.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: CC makes C::B hang in ExpandBackticks
« Reply #46 on: January 06, 2013, 03:59:42 am »
Green light for commit.
compiler: fix macro replacement bug; fix wxExecute related bug; add sanity check

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: CC makes C::B hang in ExpandBackticks
« Reply #47 on: January 09, 2013, 12:37:09 am »
Jens do you have bt for all threads? (for the original problem)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: CC makes C::B hang in ExpandBackticks
« Reply #48 on: January 09, 2013, 12:55:09 am »
Quote
#0  0x00007ffff421d47f in wxPipeInputStream::CanRead() const () from /usr/lib64/libwx_baseu-2.8.so.0
#1  0x00007ffff488b4fb in wxGUIAppTraits::WaitForChild(wxExecuteData&) () from /usr/lib64/libwx_gtk2u_core-2.8.so.0
#2  0x00007ffff421de1e in wxExecute(wchar_t**, int, wxProcess*) () from /usr/lib64/libwx_baseu-2.8.so.0
#3  0x00007ffff421e863 in wxExecute(wxString const&, int, wxProcess*) () from /usr/lib64/libwx_baseu-2.8.so.0
#4  0x00007ffff421b950 in ?? () from /usr/lib64/libwx_baseu-2.8.so.0
#5  0x00007ffff3b823fb in ExpandBackticks (str=...) at /home/obfuscated/projects/codeblocks/git/src/sdk/globals.cpp:849
#6  0x00007ffff3b1534a in CompilerCommandGenerator::SetupCompilerOptions (this=0x26eae40, compiler=0x18c39d0, target=0x1ccd0a0) at /home/obfuscated/projects/codeblocks/git/src/sdk/compilercommandgenerator.cpp:936
#7  0x00007ffff3b0f554 in CompilerCommandGenerator::Init (this=0x26eae40, project=0x1bf2cc0) at /home/obfuscated/projects/codeblocks/git/src/sdk/compilercommandgenerator.cpp:164
#8  0x00007fffe4783483 in CompilerMINGW::GetCommandGenerator (this=0x18c39d0, project=0x1bf2cc0) at /home/obfuscated/projects/codeblocks/git/src/plugins/compilergcc/compilerMINGW.cpp:51
#9  0x00007fffd77d767e in NativeParser::AddCompilerDirs (this=0x17cbd90, project=0x1bf2cc0, parser=0x1cceb60) at /home/obfuscated/projects/codeblocks/git/src/plugins/codecompletion/nativeparser.cpp:1988
#10 0x00007fffd77d0717 in NativeParser::DoFullParsing (this=0x17cbd90, project=0x1bf2cc0, parser=0x1cceb60) at /home/obfuscated/projects/codeblocks/git/src/plugins/codecompletion/nativeparser.cpp:1044
#11 0x00007fffd77ce021 in NativeParser::CreateParser (this=0x17cbd90, project=0x1bf2cc0) at /home/obfuscated/projects/codeblocks/git/src/plugins/codecompletion/nativeparser.cpp:570
#12 0x00007fffd77da80f in NativeParser::OnEditorActivated (this=0x17cbd90, editor=0x24f0240) at /home/obfuscated/projects/codeblocks/git/src/plugins/codecompletion/nativeparser.cpp:2605
#13 0x00007fffd77ac5e0 in CodeCompletion::OnEditorActivatedTimer (this=0x17cbd10, event=...) at /home/obfuscated/projects/codeblocks/git/src/plugins/codecompletion/codecompletion.cpp:3640
#14 0x00007ffff4219e26 in wxEvtHandler::ProcessEventIfMatches(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0
#15 0x00007ffff4219fab in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) () from /usr/lib64/libwx_baseu-2.8.so.0
#16 0x00007ffff421a2e4 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0
#17 0x00007ffff49873ee in wxTimerBase::Notify() () from /usr/lib64/libwx_gtk2u_core-2.8.so.0
#18 0x00007ffff48ae1cb in ?? () from /usr/lib64/libwx_gtk2u_core-2.8.so.0
#19 0x00007ffff59b85ab in ?? () from /usr/lib64/libglib-2.0.so.0
#20 0x00007ffff59b79e2 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#21 0x00007ffff59b7d28 in ?? () from /usr/lib64/libglib-2.0.so.0
#22 0x00007ffff59b7de4 in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#23 0x00007ffff78d8b31 in gtk_main_iteration () from /usr/lib64/libgtk-x11-2.0.so.0
#24 0x00007ffff4892ba5 in wxApp::Yield(bool) () from /usr/lib64/libwx_gtk2u_core-2.8.so.0
#25 0x00007ffff488b5c5 in wxGUIAppTraits::WaitForChild(wxExecuteData&) () from /usr/lib64/libwx_gtk2u_core-2.8.so.0
#26 0x00007ffff421de1e in wxExecute(wchar_t**, int, wxProcess*) () from /usr/lib64/libwx_baseu-2.8.so.0
#27 0x00007ffff421e863 in wxExecute(wxString const&, int, wxProcess*) () from /usr/lib64/libwx_baseu-2.8.so.0
#28 0x00007ffff421b950 in ?? () from /usr/lib64/libwx_baseu-2.8.so.0
#29 0x00007ffff3b823fb in ExpandBackticks (str=...) at /home/obfuscated/projects/codeblocks/git/src/sdk/globals.cpp:849
#30 0x00007ffff3b1568e in CompilerCommandGenerator::SetupLinkerOptions (this=0x2698bc0, compiler=0x18c39d0, target=0x1cd3ad0) at /home/obfuscated/projects/codeblocks/git/src/sdk/compilercommandgenerator.cpp:965
#31 0x00007ffff3b0f5c7 in CompilerCommandGenerator::Init (this=0x2698bc0, project=0x1bf2cc0) at /home/obfuscated/projects/codeblocks/git/src/sdk/compilercommandgenerator.cpp:165
#32 0x00007fffe4783483 in CompilerMINGW::GetCommandGenerator (this=0x18c39d0, project=0x1bf2cc0) at /home/obfuscated/projects/codeblocks/git/src/plugins/compilergcc/compilerMINGW.cpp:51
#33 0x00007fffd77d767e in NativeParser::AddCompilerDirs (this=0x17cbd90, project=0x1bf2cc0, parser=0x2696830) at /home/obfuscated/projects/codeblocks/git/src/plugins/codecompletion/nativeparser.cpp:1988
#34 0x00007fffd77d0717 in NativeParser::DoFullParsing (this=0x17cbd90, project=0x1bf2cc0, parser=0x2696830) at /home/obfuscated/projects/codeblocks/git/src/plugins/codecompletion/nativeparser.cpp:1044
#35 0x00007fffd77ce021 in NativeParser::CreateParser (this=0x17cbd90, project=0x1bf2cc0) at /home/obfuscated/projects/codeblocks/git/src/plugins/codecompletion/nativeparser.cpp:570
#36 0x00007fffd77a5a4c in CodeCompletion::OnProjectActivated (this=0x17cbd10, event=...) at /home/obfuscated/projects/codeblocks/git/src/plugins/codecompletion/codecompletion.cpp:2385
#37 0x00007fffd77c213b in cbEventFunctor<CodeCompletion, CodeBlocksEvent>::Call (this=0x1b7c650, event=...) at include/cbfunctor.h:35
#38 0x00007ffff3b9967d in Manager::ProcessEvent (this=0x89e730, event=...) at /home/obfuscated/projects/codeblocks/git/src/sdk/manager.cpp:179
#39 0x00007ffff3bb8b52 in PluginManager::NotifyPlugins (this=0x117d880, event=...) at /home/obfuscated/projects/codeblocks/git/src/sdk/pluginmanager.cpp:1445
#40 0x00007ffff3bdb224 in ProjectManager::SetProject (this=0xdd4120, project=0x1bf2cc0, refresh=true) at /home/obfuscated/projects/codeblocks/git/src/sdk/projectmanager.cpp:494
#41 0x00007ffff3bdde36 in ProjectManager::LoadProject (this=0xdd4120, filename=..., activateIt=true) at /home/obfuscated/projects/codeblocks/git/src/sdk/projectmanager.cpp:802
#42 0x000000000049bb09 in MainFrame::DoOpenProject (this=0x16b50b0, filename=..., addToHistory=true) at /home/obfuscated/projects/codeblocks/git/src/src/main.cpp:1826
#43 0x000000000049b781 in MainFrame::OpenGeneric (this=0x16b50b0, filename=..., addToHistory=true) at /home/obfuscated/projects/codeblocks/git/src/src/main.cpp:1775
#44 0x000000000049e343 in MainFrame::OnStartHereLink (this=0x16b50b0, event=...) at /home/obfuscated/projects/codeblocks/git/src/src/main.cpp:2145
#45 0x00007ffff4219e26 in wxEvtHandler::ProcessEventIfMatches(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0
#46 0x00007ffff4219fab in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) () from /usr/lib64/libwx_baseu-2.8.so.0
#47 0x00007ffff421a2e4 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0
#48 0x00007ffff4219d92 in wxEvtHandler::ProcessPendingEvents() () from /usr/lib64/libwx_baseu-2.8.so.0
#49 0x00007ffff41972a9 in wxAppConsole::ProcessPendingEvents() () from /usr/lib64/libwx_baseu-2.8.so.0
#50 0x00007ffff4919c2a in wxAppBase::ProcessIdle() () from /usr/lib64/libwx_gtk2u_core-2.8.so.0
#51 0x00007ffff489208e in ?? () from /usr/lib64/libwx_gtk2u_core-2.8.so.0
#52 0x00007ffff59b79e2 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#53 0x00007ffff59b7d28 in ?? () from /usr/lib64/libglib-2.0.so.0
#54 0x00007ffff59b811a in g_main_loop_run () from /usr/lib64/libglib-2.0.so.0
#55 0x00007ffff78d8927 in gtk_main () from /usr/lib64/libgtk-x11-2.0.so.0
#56 0x00007ffff48a6528 in wxEventLoop::Run() () from /usr/lib64/libwx_gtk2u_core-2.8.so.0
#57 0x00007ffff4919a5b in wxAppBase::MainLoop() () from /usr/lib64/libwx_gtk2u_core-2.8.so.0
#58 0x0000000000455cec in CodeBlocksApp::OnRun (this=0x7acb80) at /home/obfuscated/projects/codeblocks/git/src/src/app.cpp:787
#59 0x00007ffff41c7cda in wxEntry(int&, wchar_t**) () from /usr/lib64/libwx_baseu-2.8.so.0
#60 0x00000000004532b9 in main (argc=8, argv=0x7fffffffdac8) at /home/obfuscated/projects/codeblocks/git/src/src/app.cpp:266

I doubt that wxExecute is re-entrant function.

This patch makes it 100% reproducible:
Code
diff --git a/src/sdk/globals.cpp b/src/sdk/globals.cpp
index f12fd76..38f672e 100644
--- a/src/sdk/globals.cpp
+++ b/src/sdk/globals.cpp
@@ -841,7 +841,7 @@ wxString ExpandBackticks(wxString& str) // backticks are written in-place to str
         }
         else
         {
-            Manager::Get()->GetLogManager()->DebugLog(F(_T("Caching result of `%s`"), cmd.wx_str()));
+//            Manager::Get()->GetLogManager()->DebugLog(F(_T("Caching result of `%s`"), cmd.wx_str()));
             wxArrayString output;
             if (platform::WindowsVersion() >= platform::winver_WindowsNT2000)
                 wxExecute(_T("cmd /c ") + cmd, output, wxEXEC_NODISABLE);
@@ -849,8 +849,8 @@ wxString ExpandBackticks(wxString& str) // backticks are written in-place to str
                 wxExecute(cmd, output, wxEXEC_NODISABLE);
             bt = GetStringFromArray(output, _T(" "), false);
             // add it in the cache
-            m_Backticks[cmd] = bt;
-            Manager::Get()->GetLogManager()->DebugLog(_T("Cached"));
+            //m_Backticks[cmd] = bt;
+//            Manager::Get()->GetLogManager()->DebugLog(_T("Cached"));
         }
         ret << bt << _T(' ');
         str = str.substr(0, start) + bt + str.substr(end + 1, wxString::npos);
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: CC makes C::B hang in ExpandBackticks
« Reply #49 on: January 09, 2013, 01:01:22 am »
Jens do you have bt for all threads? (for the original problem)
No just for the main thread.
I will try to get a bt for all tomorrow.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: CC makes C::B hang in ExpandBackticks
« Reply #50 on: January 09, 2013, 08:37:11 am »
Jens do you have bt for all threads? (for the original problem)
No just for the main thread.
I will try to get a bt for all tomorrow.
I attach two backtraces, one with all threads and a full bt from thread 1.
But nothing didn't change as far as I can see.

But I found one interestant thing:
I have a defunct process with the commandline "gtk2-unicode-re".
That's the script which is called by the "wx-config"-script on fedora ("/usr/lib64/wx/config/gtk2-unicode-release-2.8").

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: CC makes C::B hang in ExpandBackticks
« Reply #51 on: January 09, 2013, 08:53:52 am »
I guess you're not using the reproducer patch, because you bt is different.
Also, I guess we're hitting some wxexecute bug here.

Have you tried to use slower running script in the backtick expression? Some script with sleep in it for example?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: CC makes C::B hang in ExpandBackticks
« Reply #52 on: January 09, 2013, 09:14:41 am »
I guess you're not using the reproducer patch, because you bt is different.
Does that apply to Windows, too? And is it really just commenting the log output and disable caching of backtick'd expressions? ??? I wonder if there is a way to reproduce it on Windows, too.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: CC makes C::B hang in ExpandBackticks
« Reply #53 on: January 09, 2013, 10:05:13 am »
And is it really just commenting the log output and disable caching of backtick'd expressions?
Yes and yes.
But looking at bt provided I think the problem is somewhere else.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline p2rkw

  • Almost regular
  • **
  • Posts: 142
Re: CC makes C::B hang in ExpandBackticks
« Reply #54 on: January 13, 2013, 03:30:28 am »
Quote
But looking at bt provided I think the problem is somewhere else.
It may be this bug: http://trac.wxwidgets.org/ticket/12636 but its quite old.

I find out that codeblocks spawned from another codeblocks instance doesn't have opened "/tmp/CODEBLOCKSusername.socket" file.

When I use "Debug" instead of "Build and run" command then new instance of codeblocks doesn't hang.