Author Topic: cc-branch crashes on linux  (Read 22085 times)

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
cc-branch crashes on linux
« on: August 22, 2010, 10:27:12 pm »
The cc-branch crashes reproucible on linux, if <wx/hashmap.h> is parsed.
Ther crash happens in wxString Tokenizer::ReadToEOL(bool nestBraces, bool stripUnneeded) when #define _WX_DECLARE_HASHTABLE( [...] is parsed.

After many debugging I found the cause.
Normally if we reach the backslash before the EOL, the space(s) before the backslash and the backslash itself are removed from buffer by decrementing the pointer p and after that moving to the next char:
Code
while (*(--p) <= _T(' ') && p > buffer)

In some rare cases we just appended the buffer to the return-string and set the temporary pointer p to the beginning of buffer. If we now decrement p and look if the character it points to is less or equal ' ' we get a segfault.
The same might happen some lines later.

This can only happen if the buffer is smaller than the line and if the next character (after appending buffer to str) is the backslash before the EOL.

I attach a project wher this happens (at least on linux 64-bit), I just copied the define of _WX_DECLARE_HASHTABLE into main.cpp and removed everything else.

The following patch avoids that problem, but it seems to change the behaviou alittle bit (for a simple hello-world project one file more is parsed, but less tokens are found).
Another approach would be to leave everything as it is, but do it only if p is greater than buffer and if it is not (buffer has already been appended to str), remove the trailing spaces from str.
It's also easy to do, but I am not sure whether it is needed, or if we can leave the spaces.

It would be nice if the cc-gurus can have alook at the patch:

Code
Index: src/plugins/codecompletion/parser/tokenizer.cpp
===================================================================
--- src/plugins/codecompletion/parser/tokenizer.cpp (Revision 6508)
+++ src/plugins/codecompletion/parser/tokenizer.cpp (Arbeitskopie)
@@ -410,13 +410,13 @@
                 break;
             else
             {
-                while (*(--p) <= _T(' ') && p > buffer)
+                while ((p > buffer) && *(--p) <= _T(' '))
                     ;
                 MoveToNextChar();
             }
         }
 
-        while (*(p - 1) <= _T(' ') && --p > buffer)
+        while (p > buffer && *(--p) <= _T(' '))
             ;
         str.Append(buffer, p - buffer);
 

The attached patch is the same as above, but with abuild-fix and a correction of slashes in the unix project-file.

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: cc-branch crashes on linux
« Reply #1 on: August 23, 2010, 06:10:10 am »
Thank Jens!

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: cc-branch crashes on linux
« Reply #2 on: August 23, 2010, 06:19:44 am »
Hi, Jens, can you give me a favor?
In Ubuntu 10.04, if apply this patch, will lead C::B can not load libcodecompletion.so.
I check it more times, but i can not find the reason.
I need you help. ^_^
« Last Edit: August 24, 2010, 12:46:10 am by Loaden »

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: cc-branch crashes on linux
« Reply #3 on: August 23, 2010, 07:37:45 am »
WOW, I got the reason.
THAT IS: We must add "classnavigator.cpp/h" to project!!
Solved now!
« Last Edit: August 23, 2010, 07:39:58 am by Loaden »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9613
Re: cc-branch crashes on linux
« Reply #4 on: August 23, 2010, 08:03:53 am »
The following patch avoids that problem, but it seems to change the behaviou alittle bit (for a simple hello-world project one file more is parsed, but less tokens are found).
Ooops - sounds weired. You mean for a single file "Hello World" project?! :shock:

@Loaden: What could be the reason for this?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: cc-branch crashes on linux
« Reply #5 on: August 23, 2010, 08:13:17 am »
The following patch avoids that problem, but it seems to change the behaviou alittle bit (for a simple hello-world project one file more is parsed, but less tokens are found).
Ooops - sounds weired. You mean for a single file "Hello World" project?! :shock:

@Loaden: What could be the reason for this?!
I am a little busy, will comment later.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: cc-branch crashes on linux
« Reply #6 on: August 23, 2010, 09:17:49 am »
Another approach would be to leave everything as it is, but do it only if p is greater than buffer and if it is not (buffer has already been appended to str), remove the trailing spaces from str.
Next patch, this time it generates the exactly same tokens-tree, -list, include-dirs and file-list:
Code
Index: src/plugins/codecompletion/parser/tokenizer.cpp
===================================================================
--- src/plugins/codecompletion/parser/tokenizer.cpp (Revision 6508)
+++ src/plugins/codecompletion/parser/tokenizer.cpp (Arbeitskopie)
@@ -410,14 +410,34 @@
                 break;
             else
             {
-                while (*(--p) <= _T(' ') && p > buffer)
-                    ;
+                // only work with p if the buffer is not just appended (p==buffer)
+                // otherwise remove the traling spaces from str (avoid segfault on linux in rare cases)
+                if(p > buffer)
+                {
+                    while (*(--p) <= _T(' ') && p > buffer)
+                        ;
+                }
+                else
+                {
+                    while(!str.IsEmpty() && str.Last() <= _T(' '))
+                        str.RemoveLast();
+                }
                 MoveToNextChar();
             }
         }
 
-        while (*(p - 1) <= _T(' ') && --p > buffer)
-            ;
+        // only work with p if the buffer is not just appended (p==buffer)
+        // otherwise remove the traling spaces from str (avoid segfault on linux in rare cases)
+        if(p > buffer)
+        {
+            while (*(p - 1) <= _T(' ') && --p > buffer)
+                    ;
+        }
+        else
+        {
+            while(!str.IsEmpty() && str.Last() <= _T(' '))
+                str.RemoveLast();
+        }
         str.Append(buffer, p - buffer);
 
         TRACE(_T("ReadToEOL(): (END) We are now at line %d, CurrentChar='%c', PreviousChar='%c', NextChar='%c'"),

[attachment deleted by admin]

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: cc-branch crashes on linux
« Reply #7 on: August 23, 2010, 09:20:52 am »
The following patch avoids that problem, but it seems to change the behaviou alittle bit (for a simple hello-world project one file more is parsed, but less tokens are found).
I'm back.
Need changed to:
Quote
-        while (*(p - 1) <= _T(' ') && --p > buffer)
-            ;
+        while (p > buffer && *(p - 1) <= _T(' '))
+            --p;

This patch fixed crash in ReadParentheses too.
And do some simple optimization.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: cc-branch crashes on linux
« Reply #8 on: August 23, 2010, 09:36:11 am »
Tested and confirmed, no crash and identical tokens-list etc. for test-project.

Thank you for the quick fix !

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5273
Re: cc-branch crashes on linux
« Reply #9 on: August 23, 2010, 07:45:28 pm »
I don't know if it is related, or already fixed by above mentioned patch, but for me CB is crashing also a lot.
Whenever I have method call for example, and just before the closing ')' of the call I press comma (,) CB dies on me (well never comes back and I have to kill it).

x.foo(1,2,3);  --> before the ) and after the 3 press comma and it crashes.

Other way to reproduce. Have CB create a console application,

Go to the line of void main(), and try to type "int argc," , once the "," has been typed --> crash.

Can the above path be committed to cc branch.

PS : I am on linux

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5273
Re: cc-branch crashes on linux
« Reply #10 on: August 23, 2010, 09:15:00 pm »
I just svn updated (cc branch and rev 6522) and the problem still occurs. Anyone else can reproduce this ?

EDIT : I did even a make clean && make : no luck, issue remains.
« Last Edit: August 23, 2010, 09:42:30 pm by killerbot »

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: cc-branch crashes on linux
« Reply #11 on: August 24, 2010, 12:49:38 am »
I don't know if it is related, or already fixed by above mentioned patch, but for me CB is crashing also a lot.
Whenever I have method call for example, and just before the closing ')' of the call I press comma (,) CB dies on me (well never comes back and I have to kill it).

x.foo(1,2,3);  --> before the ) and after the 3 press comma and it crashes.

Other way to reproduce. Have CB create a console application,

Go to the line of void main(), and try to type "int argc," , once the "," has been typed --> crash.

Can the above path be committed to cc branch.

PS : I am on linux
This is another issue.
I will fix it soon, please waiting.

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: cc-branch crashes on linux
« Reply #12 on: August 24, 2010, 02:47:58 am »
Fixed!

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5273
Re: cc-branch crashes on linux
« Reply #13 on: August 24, 2010, 07:00:18 am »
I can confirm this patch fixes the issue. Bring it on the cc branch ;-)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5273
Re: cc-branch crashes on linux
« Reply #14 on: August 24, 2010, 11:00:14 am »
today, already had a lot of other crashes.
From the log xml, this is the stack part (all crashes resulted in the same dump like this) :
Code
  <stack>
    <frame level="0"/>
    <frame level="1" function="NativeParser::OnEditorActivatedTimer(wxTimerEvent&amp;)" offset="0000024d"/>
    <frame level="2" function="wxEvtHandler::ProcessEventIfMatches(wxEventTableEntryBase const&amp;, wxEvtHandler*, wxEvent&amp;)" offset="00000055"/>
    <frame level="3" function="wxEventHashTable::HandleEvent(wxEvent&amp;, wxEvtHandler*)" offset="000000ac"/>
    <frame level="4" function="wxEvtHandler::ProcessEvent(wxEvent&amp;)" offset="000000b4"/>
    <frame level="5" function="wxTimerBase::Notify()" offset="0000006e"/>
    <frame level="6"/>
    <frame level="7"/>
    <frame level="8" function="g_main_context_dispatch" offset="000001f3"/>
    <frame level="9"/>
    <frame level="10" function="g_main_loop_run" offset="00000195"/>
    <frame level="11" function="gtk_main" offset="000000a7"/>
    <frame level="12" function="wxEventLoop::Run()" offset="00000048"/>
    <frame level="13" function="wxAppBase::MainLoop()" offset="0000004b"/>
  </stack>

Hopefully this can be fixed.

I also have the *feeling* that cc works less good then before. Several times nothing comes up, where I think in the past it did. As said : a *feeling*.


EDIT : I found a way to reproduce this in my working environment (didn't try with a small project).
So I have a workspace with several projects, some files of these projects are open. I drag and drop a cpp file to CB (this file doesn't belong to any of the projects). CB shows the file.
Then I select the tab of one of those other open files (which are part of the project). All still is ok, then I select the tab of the "open non project file" --> crash.

EDIT 2 : tried this with a small project (generated by CB), and same recipe as in the EDIT above.
« Last Edit: August 24, 2010, 11:07:27 am by killerbot »

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: cc-branch crashes on linux
« Reply #15 on: August 24, 2010, 11:04:17 am »
It's at least much slower.

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: cc-branch crashes on linux
« Reply #16 on: August 24, 2010, 02:10:27 pm »
It's at least much slower.
Here is the test log on linux.
Quote
10.05:
Parsing stage done (1531 total parsed files, 58540 tokens in 0 minute(s), 7.808 seconds).

CC branch -O0
Project 'Code::Blocks - Unix' parsing stage done (1250 total parsed files, 64146 tokens in 0 minute(s), 14.026 seconds).

CC branch -O2
Project 'Code::Blocks - Unix' parsing stage done (1250 total parsed files, 64147 tokens in 0 minute(s), 12.685 seconds).

We can see that, cc branch get more tokens, and handle more, like condition preprocessor handle, function-like macro handle...e.g.
You can open the "-O2" option, can make cc faster.

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: cc-branch crashes on linux
« Reply #17 on: August 24, 2010, 02:21:54 pm »
Hopefully this can be fixed.

EDIT : I found a way to reproduce this in my working environment (didn't try with a small project).
So I have a workspace with several projects, some files of these projects are open. I drag and drop a cpp file to CB (this file doesn't belong to any of the projects). CB shows the file.
Then I select the tab of one of those other open files (which are part of the project). All still is ok, then I select the tab of the "open non project file" --> crash.

EDIT 2 : tried this with a small project (generated by CB), and same recipe as in the EDIT above.
I will fix it.

I also have the *feeling* that cc works less good then before. Several times nothing comes up, where I think in the past it did. As said : a *feeling*.
Could you send me a test project?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13153
    • Travis build status
Re: cc-branch crashes on linux
« Reply #18 on: August 24, 2010, 02:23:29 pm »
Why the number of parsed files is less that the trunk version 1250 vs 1531?
(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 jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: cc-branch crashes on linux
« Reply #19 on: August 24, 2010, 02:27:59 pm »
Why the number of parsed files is less that the trunk version 1250 vs 1531?
Because the trunk version also has non sources and headers in the files-list (xrc and others).

I do not know the cause, but I think it parses all project-files that can be opened (just a wild guess).

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: cc-branch crashes on linux
« Reply #20 on: August 24, 2010, 02:29:14 pm »
Why the number of parsed files is less that the trunk version 1250 vs 1531?
Because there are many parsed header files is wrong!
Code
#if 0
#include <a.h>
#include <b.h>
#include <c.h>
#include <d.h>
#include <e.h>
#else
#include <f.h>
#endif

In trunk(or 10.05), cc will parse the #if condition preprocessor:
#if 0
#include <a.h>
...

But in cc branch, will parse the #else condition preprocessor:
#else
#include <f.h>

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: cc-branch crashes on linux
« Reply #21 on: August 24, 2010, 02:35:20 pm »
It's at least much slower.
Here is the test log on linux.
Quote
10.05:
Parsing stage done (1531 total parsed files, 58540 tokens in 0 minute(s), 7.808 seconds).

CC branch -O0
Project 'Code::Blocks - Unix' parsing stage done (1250 total parsed files, 64146 tokens in 0 minute(s), 14.026 seconds).

CC branch -O2
Project 'Code::Blocks - Unix' parsing stage done (1250 total parsed files, 64147 tokens in 0 minute(s), 12.685 seconds).

We can see that, cc branch get more tokens, and handle more, like condition preprocessor handle, function-like macro handle...e.g.
You can open the "-O2" option, can make cc faster.
Another reason: In current cc branch, we need get system headers list in another thread.
So, It's need some time.

When i open the CB project again, it's make faster.
Quote
Project 'Code::Blocks - Unix' parsing stage done (1250 total parsed files, 64147 tokens in 0 minute(s), 6.390 seconds).

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: cc-branch crashes on linux
« Reply #22 on: August 24, 2010, 02:58:15 pm »
Hopefully this can be fixed.

EDIT : I found a way to reproduce this in my working environment (didn't try with a small project).
So I have a workspace with several projects, some files of these projects are open. I drag and drop a cpp file to CB (this file doesn't belong to any of the projects). CB shows the file.
Then I select the tab of one of those other open files (which are part of the project). All still is ok, then I select the tab of the "open non project file" --> crash.

EDIT 2 : tried this with a small project (generated by CB), and same recipe as in the EDIT above.
I will fix it.
Fixed!

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5316
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: cc-branch crashes on linux
« Reply #23 on: August 24, 2010, 03:00:45 pm »
It's at least much slower.
compared with which?
As loaden said:
The conditional preprocessor and macro expansion takes a lot of time, also make cc get more precise tokens.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5316
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: cc-branch crashes on linux
« Reply #24 on: August 24, 2010, 03:12:13 pm »
Btw:
About the performance issue, I have discussed with loaden, currently, we can't use "multi-thread" of parserthread, because wxString is not thread-safe. so you can see, the memory pool is force to run only one thread.

Code
Parser::Parser(wxEvtHandler* parent) :
    m_pParent(parent),
    m_UsingCache(false),
    m_Pool(this, wxNewId(), 1), // in the meanwhile it'll have to be forced to 1
So, this way, CC can only run on a single CPU, my experience is my dualcore CPU is under only 50% usage when CC do a batch parsing.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: cc-branch crashes on linux
« Reply #25 on: August 24, 2010, 03:26:26 pm »
It's at least much slower.
compared with which?
As loaden said:
The conditional preprocessor and macro expansion takes a lot of time, also make cc get more precise tokens.

trunk (svn r6525 compiled with -O2)
not first time parsing, but several reparses to have as much as possible in OS-buffer (debian 64-bit with 4 GB memory)
Code
Parsing stage done (1521 total parsed files, 50655 tokens in 0 minute(s), 2.924 seconds).
...
Parsing stage done (1521 total parsed files, 50655 tokens in 0 minute(s), 2.680 seconds).

cc-branch (svnr6524)
Code
Project 'Code::Blocks - Unix' parsing stage done (1249 total parsed files, 66373 tokens in 0 minute(s), 6.697 seconds).
...
Project 'Code::Blocks - Unix' parsing stage done (1249 total parsed files, 66373 tokens in 0 minute(s), 6.659 seconds).

cc-branch (svnr6524 codecompletion-plugin compiled with -O2)
Code
Project 'Code::Blocks - Unix' parsing stage done (1249 total parsed files, 66373 tokens in 0 minute(s), 3.012 seconds).
...
Project 'Code::Blocks - Unix' parsing stage done (1249 total parsed files, 66373 tokens in 0 minute(s), 3.019 seconds).

It looks like the optimization does the trick.
It's turned off by default in C::B project file (at least on linux), but turned on in automake-system.

But it still feels slower, the cause might be the much greater amount of tokens that have to be added to symbols-browser.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5273
Re: cc-branch crashes on linux
« Reply #26 on: August 24, 2010, 08:25:42 pm »
hi, the patch has fixed the crash, but now I get a crash whe nCB closes (again when we having been switching between a non project file).
This is a stack trace :
Code
  <stack>
    <frame level="0"/>
    <frame level="1" function="TextCtrlLogger::Append(wxString const&amp;, Logger::level)" offset="00000064"/>
    <frame level="2" function="NativeParser::ClearParsers()" offset="000000b3"/>
    <frame level="3" function="CodeCompletion::OnRelease(bool)" offset="0000003f"/>
    <frame level="4" function="cbPlugin::Release(bool)" offset="00000065"/>
    <frame level="5" function="PluginManager::DetachPlugin(cbPlugin*)" offset="00000043"/>
    <frame level="6" function="PluginManager::UnloadPlugin(cbPlugin*)" offset="0000001a"/>
    <frame level="7" function="PluginManager::UnloadAllPlugins()" offset="00000023"/>
    <frame level="8" function="PluginManager::~PluginManager()" offset="00000022"/>
    <frame level="9" function="PluginManager::~PluginManager()" offset="00000009"/>
    <frame level="10" function="Manager::Shutdown()" offset="00000076"/>
  </stack>

EDIT : I tried this 3 times, each time crash, but only once the rpt xml file contained a stack trace, the other times only a list of modules.
« Last Edit: August 24, 2010, 08:29:42 pm by killerbot »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9613
Re: cc-branch crashes on linux
« Reply #27 on: August 24, 2010, 08:31:06 pm »
hi, the patch has fixed the crash, but now I get a crash whe nCB closes (again when we having been switching between a non project file).
This is a stack trace :
Code
  <stack>
    <frame level="0"/>
    <frame level="1" function="TextCtrlLogger::Append(wxString const&amp;, Logger::level)" offset="00000064"/>
    <frame level="2" function="NativeParser::ClearParsers()" offset="000000b3"/>
    <frame level="3" function="CodeCompletion::OnRelease(bool)" offset="0000003f"/>
    <frame level="4" function="cbPlugin::Release(bool)" offset="00000065"/>
    <frame level="5" function="PluginManager::DetachPlugin(cbPlugin*)" offset="00000043"/>
    <frame level="6" function="PluginManager::UnloadPlugin(cbPlugin*)" offset="0000001a"/>
    <frame level="7" function="PluginManager::UnloadAllPlugins()" offset="00000023"/>
    <frame level="8" function="PluginManager::~PluginManager()" offset="00000022"/>
    <frame level="9" function="PluginManager::~PluginManager()" offset="00000009"/>
    <frame level="10" function="Manager::Shutdown()" offset="00000076"/>
  </stack>
In ClearParsers() which is also called from the destructor there is an logger output but no check if the app is shutting down. So the output to the log fails. This can be fixed by either just removing this log message or checking if C::B shuts down and if so, not posting anything to the logger.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9613
Re: cc-branch crashes on linux
« Reply #28 on: August 24, 2010, 08:39:39 pm »
In ClearParsers() which is also called from the destructor there is an logger output but no check if the app is shutting down. So the output to the log fails. This can be fixed by either just removing this log message or checking if C::B shuts down and if so, not posting anything to the logger.
Wait a sec... even worse! TextCtrlLogger derives from Loggers which has a virtual destructor, but TextCtrlLogger does not implement a destructor. Thus the control of the TextCtrlLogger does not get cleared properly (most likely). I wonder why the compiler does not complain about the missing implementation of the destructor... or am I missing something (it's late and I had a long day...).

BTW: All sanity checks in the TextCtrlLogger are useless therefore...?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: cc-branch crashes on linux
« Reply #29 on: August 25, 2010, 04:28:56 am »
hi, the patch has fixed the crash, but now I get a crash whe nCB closes (again when we having been switching between a non project file).
This is a stack trace :
Code
  <stack>
    <frame level="0"/>
    <frame level="1" function="TextCtrlLogger::Append(wxString const&amp;, Logger::level)" offset="00000064"/>
    <frame level="2" function="NativeParser::ClearParsers()" offset="000000b3"/>
    <frame level="3" function="CodeCompletion::OnRelease(bool)" offset="0000003f"/>
    <frame level="4" function="cbPlugin::Release(bool)" offset="00000065"/>
    <frame level="5" function="PluginManager::DetachPlugin(cbPlugin*)" offset="00000043"/>
    <frame level="6" function="PluginManager::UnloadPlugin(cbPlugin*)" offset="0000001a"/>
    <frame level="7" function="PluginManager::UnloadAllPlugins()" offset="00000023"/>
    <frame level="8" function="PluginManager::~PluginManager()" offset="00000022"/>
    <frame level="9" function="PluginManager::~PluginManager()" offset="00000009"/>
    <frame level="10" function="Manager::Shutdown()" offset="00000076"/>
  </stack>
In ClearParsers() which is also called from the destructor there is an logger output but no check if the app is shutting down. So the output to the log fails. This can be fixed by either just removing this log message or checking if C::B shuts down and if so, not posting anything to the logger.
I personally think that not CC bug.
We need find the reason?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9613
Re: cc-branch crashes on linux
« Reply #30 on: August 25, 2010, 06:56:41 am »
I personally think that not CC bug.
We need find the reason?
True - it's not as CC bug, but CC could avoid it.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13153
    • Travis build status
Re: cc-branch crashes on linux
« Reply #31 on: August 25, 2010, 11:06:51 am »
Hm, Looks the same as the one in the debugger branch.
I think this should be fixed in C::B's sdk, not in every plugin, it will be easier I suppose :)
(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 killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5273
Re: cc-branch crashes on linux
« Reply #32 on: August 25, 2010, 12:14:31 pm »
but rather urgently ;-)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: cc-branch crashes on linux
« Reply #33 on: August 25, 2010, 12:32:51 pm »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9613
Re: cc-branch crashes on linux
« Reply #34 on: August 25, 2010, 01:44:55 pm »
I think this should be fixed in C::B's sdk, not in every plugin, it will be easier I suppose :)
True, If what I said is correct. As the loggers is an implementation of Thomas, I wonder what he believes is the right thing to do.

I would implement the destructor for the relevant loggers (including TextCtrlLogger) and set the control pointer to zero (NOT deleting it, as deletion will be done by the parent component in wxwidgets).

Any objections / thoughts / hints on that topic?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5273
Re: cc-branch crashes on linux
« Reply #35 on: August 25, 2010, 02:38:17 pm »

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: cc-branch crashes on linux
« Reply #36 on: August 25, 2010, 02:50:48 pm »
Hi, all!
I personally hope we can publish a CC BRANCH build in the "Nightly builds" board.
Because we need more extensive testing in order to perfect the CC.
Any comments?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9613
Re: cc-branch crashes on linux
« Reply #37 on: August 25, 2010, 03:11:09 pm »
confirmed this fixes the issue.
On second thoughts:
The loggers are one of the components destroyed at last. So in fact they should be valid during the shutdown/destruction of ANY plugin.

However, logging/UI access in operations called during shutdown (of plugins) should ALWAYS check if the app is shutting down -> just as Loaden did it in the patch for the CC branch. Basically that's what this method is for!

I have (however) attached a patch concerning the loggers for testing. It shouldn't harm but may introduce some "safety"... although it's not really a "good way".

I would welcome testing and feedback (@oBFusCATed: e.g. if this "fixes" the crash in the debugger branch).

I personally hope we can publish a CC BRANCH build in the "Nightly builds" board.
I had asked killerbot to do so, I'm afraid he didn't find the time or wanted to wait until the show-stoppers are solved.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5273
Re: cc-branch crashes on linux
« Reply #38 on: August 26, 2010, 12:06:04 pm »
Quote
wanted to wait until the show-stoppers are solved.

But this weekend I will create one.

I could do all 3 of them :
regular
cc
debugger (if there are any updates ?)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: cc-branch crashes on linux
« Reply #39 on: August 26, 2010, 12:18:05 pm »
Quote
wanted to wait until the show-stoppers are solved.

But this weekend I will create one.

I could do all 3 of them :
regular
cc
debugger (if there are any updates ?)
Thanks a lot!

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5316
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: cc-branch crashes on linux
« Reply #40 on: August 26, 2010, 01:25:01 pm »
Quote
wanted to wait until the show-stoppers are solved.

But this weekend I will create one.

I could do all 3 of them :
regular
cc
debugger (if there are any updates ?)
Nice, glad to hear! thank you!!!
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13153
    • Travis build status
Re: cc-branch crashes on linux
« Reply #41 on: September 17, 2010, 02:19:54 am »
I would welcome testing and feedback (@oBFusCATed: e.g. if this "fixes" the crash in the debugger branch).
No, it doesn't, it's the same as before, the logger has control pointer pointing to the dead gui object...

Steps to reprocude:
1. start cb
2. start some app
3. attach to the app
4. close cb
(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!]