Author Topic: CodeBlocks cash when "Find declaration " on some symbol  (Read 20941 times)

Offline nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
CodeBlocks cash when "Find declaration " on some symbol
« on: February 06, 2011, 04:20:49 am »
windows 7
cb night build svn 6931
my project have a cpp file named "data_space_helper.cpp/.h"
after open this cpp file do nothing 3~4 sec, the c::b crash.
OR, do the  "Find declaration of FlowRuntimeContext",c::b crash.

do the same operator with other cpp files, OR, "Find declaration of XXX " (XXX isnot "FlowRuntimeContext"), everything ok, the c::b didn't crash.
---------
codeblocks.RPT is :
Code
-------------------

Error occured on Sunday, January 23, 2011 at 01:15:45.

E:\CodeBlocks\codeblocks.exe caused an Access Violation at location 6d8e20f5 in module E:\CodeBlocks\share\codeblocks\plugins\debugger.dll Reading from location fffffff8.

Registers:
eax=fffffff4 ebx=00000000 ecx=00000001 edx=00000000 esi=000006a9 edi=0211ee00
eip=6d8e20f5 esp=0022f3b8 ebp=0022f3bc iopl=0         nv up ei ng nz ac pe cy
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010293

Call stack:
6D8E20F5  E:\CodeBlocks\share\codeblocks\plugins\debugger.dll:6D8E20F5  _ZN8cbPlugin9OnReleaseEb
6D8E20DD  E:\CodeBlocks\share\codeblocks\plugins\debugger.dll:6D8E20DD  _ZN8cbPlugin9OnReleaseEb
6D8E2CF5  E:\CodeBlocks\share\codeblocks\plugins\debugger.dll:6D8E2CF5  _ZNK8cbPlugin9CanDetachEv
6D8D880D  E:\CodeBlocks\share\codeblocks\plugins\debugger.dll:6D8D880D  _ZN14cbWizardPlugin9BuildMenuEP9wxMenuBar
6D8B5EF6  E:\CodeBlocks\share\codeblocks\plugins\debugger.dll:6D8B5EF6
6D898C2E  E:\CodeBlocks\share\codeblocks\plugins\debugger.dll:6D898C2E
6D89BA42  E:\CodeBlocks\share\codeblocks\plugins\debugger.dll:6D89BA42
6CCC3C28  E:\CodeBlocks\wxmsw28u_gcc_cb.dll:6CCC3C28  _ZN12wxEvtHandler21ProcessEventIfMatchesERK21wxEventTableEntryBasePS_R7wxEvent
6CCC3D61  E:\CodeBlocks\wxmsw28u_gcc_cb.dll:6CCC3D61  _ZN16wxEventHashTable11HandleEventER7wxEventP12wxEvtHandler
6CCC412C  E:\CodeBlocks\wxmsw28u_gcc_cb.dll:6CCC412C  _ZN12wxEvtHandler12ProcessEventER7wxEvent
6CCC3AC0  E:\CodeBlocks\wxmsw28u_gcc_cb.dll:6CCC3AC0  _ZN12wxEvtHandler20ProcessPendingEventsEv
6CC417AE  E:\CodeBlocks\wxmsw28u_gcc_cb.dll:6CC417AE  _ZN12wxAppConsole20ProcessPendingEventsEv
6D0372ED  E:\CodeBlocks\wxmsw28u_gcc_cb.dll:6D0372ED  _ZN18wxIconLocationBaseC2ERK8wxString
76F27B45  C:\Windows\system32\USER32.dll:76F27B45  GetUserObjectInformationA
76F331EB  C:\Windows\system32\USER32.dll:76F331EB  GetClassNameW
76F34260  C:\Windows\system32\USER32.dll:76F34260  ChangeWindowMessageFilter
779A647E  C:\Windows\SYSTEM32\ntdll.dll:779A647E  KiUserCallbackDispatcher
6CCF0A7E  E:\CodeBlocks\wxmsw28u_gcc_cb.dll:6CCF0A7E  _ZN11wxEventLoop8DispatchEv
6CD84A6C  E:\CodeBlocks\wxmsw28u_gcc_cb.dll:6CD84A6C  _ZN17wxEventLoopManual3RunEv
6CD64279  E:\CodeBlocks\wxmsw28u_gcc_cb.dll:6CD64279  _ZN9wxAppBase8MainLoopEv
004058C4  E:\CodeBlocks\codeblocks.exe:004058C4
6CC7114E  E:\CodeBlocks\wxmsw28u_gcc_cb.dll:6CC7114E  _Z14wxEntryCleanupv
6CCC95D6  E:\CodeBlocks\wxmsw28u_gcc_cb.dll:6CCC95D6  _Z7wxEntryP11HINSTANCE__S0_Pci
00401D71  E:\CodeBlocks\codeblocks.exe:00401D71
0045F7F6  E:\CodeBlocks\codeblocks.exe:0045F7F6
004010DB  E:\CodeBlocks\codeblocks.exe:004010DB
00401158  E:\CodeBlocks\codeblocks.exe:00401158
77661194  C:\Windows\system32\kernel32.dll:77661194  BaseThreadInitThunk
779BB529  C:\Windows\SYSTEM32\ntdll.dll:779BB529  RtlInitializeExceptionChain
779BB4FC  C:\Windows\SYSTEM32\ntdll.dll:779BB4FC  RtlInitializeExceptionChain

==============================
add :
back to svn 6921  : occurred yet.
back to svn 6906  : occurred yet...
back to 10.02 :  now, not occurred.    :)
sorry for my english.
« Last Edit: February 06, 2011, 04:32:02 am by nanyu »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: CodeBlocks cash when "Find declaration " on some symbol
« Reply #1 on: February 06, 2011, 07:00:23 am »
after open this cpp file do nothing 3~4 sec, the c::b crash.
OR, do the  "Find declaration of FlowRuntimeContext",c::b crash.
Can you provide this file/projects (probably stripped to a minimal content)?
IT seems the crash is caused by the debugger, which is  a bit weired. Do you debug something? Do you run the debugger-enhanced nightly?
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: CodeBlocks cash when "Find declaration " on some symbol
« Reply #2 on: February 08, 2011, 08:57:37 am »
@nanyu
please supply at least the test code that we can help to test the CC crash. (you can send me email also)
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 nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
Re: CodeBlocks cash when "Find declaration " on some symbol
« Reply #3 on: February 14, 2011, 05:50:12 pm »
I have try to did that , but when no success.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: CodeBlocks cash when "Find declaration " on some symbol
« Reply #4 on: February 14, 2011, 08:35:24 pm »
I have try to did that , but when no success.
What did you try? You can also attach a minimal sample to this thread/post...
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 nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
Re: CodeBlocks cash when "Find declaration " on some symbol
« Reply #5 on: February 21, 2011, 04:44:43 pm »
@nanyu
please supply at least the test code that we can help to test the CC crash. (you can send me email also)

I have send this project to your gmail. thanks.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: CodeBlocks cash when "Find declaration " on some symbol
« Reply #6 on: February 22, 2011, 02:40:31 am »
@nanyu
please supply at least the test code that we can help to test the CC crash. (you can send me email also)

I have send this project to your gmail. thanks.
I found the bug, here is a simple test case I just create for test:
Code
namespace CollaGEN
{
namespace Engine
{

using namespace std;

using namespace Flowscript;
using namespace Dataspace;

using namespace Flowparser;
using namespace Flowdata;


int aaa;

}
}

The bug is here: parserthread.cpp line 677 changed in rev 6306 by morten (applying a patch from who? I do not know)
Code
            }
            else if (token==ParserConsts::kw_using)
            {
                wxString peek = m_Tokenizer.PeekToken();
                if (peek == ParserConsts::kw_namespace)
                {
                    // ok
                    m_Tokenizer.GetToken(); // eat namespace
                    while (true) // support full namespaces
                    {
                        m_Str << m_Tokenizer.GetToken();
                        if (m_Tokenizer.PeekToken() == ParserConsts::dcolon)
                            m_Str << m_Tokenizer.GetToken();
                        else
                            break;
                    }
                    if ((!m_Str.IsEmpty())
                            && m_pLastParent != 0L
                            && (m_pLastParent->GetSelf() != -1)
                            && (m_pLastParent->m_TokenKind == tkNamespace ) )
                    {
                        if(m_pLastParent->m_AncestorsString.IsEmpty())
                            m_pLastParent->m_AncestorsString<<m_Str;
                        else
                            m_pLastParent->m_AncestorsString<<_T(',')<<m_Str;
                    }
                }
                else
                    SkipToOneOfChars(ParserConsts::semicolonclbrace);

                m_Str.Clear();
            }

The old code was just like: rev 6302
Code
            else if (token == ParserConsts::kw_using) // using namespace ?
            {
                SkipToOneOfChars(ParserConsts::semicolonclbrace, true);
                m_Str.Clear();
            }

The wrong thing is:
Code
std
Flowscript
Dataspace
Flowparser
Flowdata

all these items will be mistakenly add to Engine's m_AncestorsString , this is totally wrong.

The one made this patch will have a review. And simply revert this code to rev 6302 I think can fix this issue.
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 nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
Re: CodeBlocks cash when "Find declaration " on some symbol
« Reply #7 on: February 22, 2011, 06:04:18 am »
I found the bug, here is a simple test case I just create for test:
The bug is here: parserthread.cpp line 677 changed in rev 6306 by morten (applying a patch from who? I do not know)
......

The wrong thing is:
Code
std
Flowscript
Dataspace
Flowparser
Flowdata

all these items will be mistakenly add to Engine's m_AncestorsString , this is totally wrong.

The one made this patch will have a review. And simply revert this code to rev 6302 I think can fix this issue.

Is this error make my c::b crash?

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: CodeBlocks cash when "Find declaration " on some symbol
« Reply #8 on: February 22, 2011, 06:37:46 am »
I found the bug, here is a simple test case I just create for test:
The bug is here: parserthread.cpp line 677 changed in rev 6306 by morten (applying a patch from who? I do not know)
......

The wrong thing is:
Code
std
Flowscript
Dataspace
Flowparser
Flowdata

all these items will be mistakenly add to Engine's m_AncestorsString , this is totally wrong.

The one made this patch will have a review. And simply revert this code to rev 6302 I think can fix this issue.

Is this error make my c::b crash?
Same question: why lead cb crash?

The rev6306 likes for resoved this issue:
Code
#include <vector>

namespace CollaGEN
{
    using namespace std;
    namespace Engine
    {
        using namespace std;
        int aaa;
    }
}

int main()
{
    CollaGEN::Engine::vector<int> v;
    CollaGEN::vector<float> vf;
    return 0;
}


Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: CodeBlocks cash when "Find declaration " on some symbol
« Reply #9 on: February 22, 2011, 07:15:08 am »
Same question: why lead cb crash?

Code
void TokensTree::RecalcInheritanceChain(Token* token)

will be called endless.
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: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: CodeBlocks cash when "Find declaration " on some symbol
« Reply #10 on: February 22, 2011, 07:19:18 am »
The rev6306 likes for resoved this issue:
Code
#include <vector>

namespace CollaGEN
{
    using namespace std;
    namespace Engine
    {
        using namespace std;
        int aaa;
    }
}

int main()
{
    CollaGEN::Engine::vector<int> v;
    CollaGEN::vector<float> vf;
    return 0;
}
Why?
I think rev 6303 has some problems.
I don't think adding "std" as "Engine" 's ancestor is a good idea, this will cause a lot of headache.
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 nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
Re: CodeBlocks cash when "Find declaration " on some symbol
« Reply #11 on: February 23, 2011, 03:59:37 am »
I have moved out all "using namespace ..." , but c::b crash yet. :(
waitting for your help..
now I install two c::b on my pc. :)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: CodeBlocks cash when "Find declaration " on some symbol
« Reply #12 on: February 23, 2011, 04:10:29 am »
I have moved out all "using namespace ..." , but c::b crash yet. :(
waitting for your help..
now I install two c::b on my pc. :)
I'm trying to find the real bug :D
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: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: CodeBlocks cash when "Find declaration " on some symbol
« Reply #13 on: February 23, 2011, 08:52:38 am »
Here is the candidate patch to solve the crash bug.

The crash bug caused when ancestors are recursive.
e.g.:
there is a token class A, its ancestorsString can be "B;C;D"
and for a token class B, its ancestorsStirng could be "A;C;D"
you see, there is a hierarchy loop.

this is mostly caused by rev 6303, because a lot of un-related ancestors were added. I think we should use another method like (use a context variable to remember the current exposed namespace instead the way rev 6303's method)

my patch does not solve the bug in rev 6303.

my patch just avoid the endless loop and crash.
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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: CodeBlocks cash when "Find declaration " on some symbol
« Reply #14 on: February 23, 2011, 11:08:13 am »
Here is the candidate patch to solve the crash bug.
[...]
my patch just avoid the endless loop and crash.
Mmmh... why don't you simply do a:
Code
    wxStringTokenizer tkz(token->m_AncestorsString, _T(","));
    token->m_AncestorsString.Clear();
Instead of all this copying (not sure how wxStringTokenizer is implemented though... :oops:)? And what about the commented stuff? You change functionality here... was that on purpose (what about side-effects)?
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