Author Topic: crash while parsing source files  (Read 22042 times)

Offline jarro_2783

  • Multiple posting newcomer
  • *
  • Posts: 99
    • Project Freedom
Re: crash while parsing source files
« Reply #15 on: March 28, 2009, 11:58:34 pm »
That seems to have fixed it, thanks.
I'm curious to know if you know which part of boost was causing the crash.
The complications of boost strike again, it finds all sorts of problems in gcc, but now it's crashing IDEs too.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: crash while parsing source files
« Reply #16 on: March 29, 2009, 01:35:20 pm »
I added my first patch to trunk.
Not the one that works for you, because it is part of a codecompletion update, that is in testing phase.

Offline jarro_2783

  • Multiple posting newcomer
  • *
  • Posts: 99
    • Project Freedom
Re: crash while parsing source files
« Reply #17 on: April 04, 2009, 01:51:00 am »
I've actually started getting another crash. Unfortunately the backtrace is a little useless.

Code
Thread 1 (Thread 0xb639f8e0 (LWP 22973)):
#0  0xb66520bc in ?? () from /lib/libc.so.6
Cannot access memory at address 0xbf242fe8

have you seen anything like this with your tests?

How's the progress on getting the other fix into trunk?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: crash while parsing source files
« Reply #18 on: April 04, 2009, 09:32:03 am »
I've actually started getting another crash. Unfortunately the backtrace is a little useless.

Code
Thread 1 (Thread 0xb639f8e0 (LWP 22973)):
#0  0xb66520bc in ?? () from /lib/libc.so.6
Cannot access memory at address 0xbf242fe8

have you seen anything like this with your tests?

How's the progress on getting the other fix into trunk?

No, did this also happen with boost-library ?
Can you reproduce it ?

If yes,  do you have a simple test-case ?

Offline jarro_2783

  • Multiple posting newcomer
  • *
  • Posts: 99
    • Project Freedom
Re: crash while parsing source files
« Reply #19 on: April 07, 2009, 01:25:15 am »
www.cse.unsw.edu.au/~jarrydb/tl-0.1.4.tar.bz2

on 64 bit it seems to be crashing in RemoveToken, my 32 bit computer doesn't say anything useful in the backtrace.
change include/tl/types.hpp and save it and it should crash.

You will probably need boost 1.38 as from last time.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: crash while parsing source files
« Reply #20 on: April 07, 2009, 07:09:34 am »
www.cse.unsw.edu.au/~jarrydb/tl-0.1.4.tar.bz2

on 64 bit it seems to be crashing in RemoveToken, my 32 bit computer doesn't say anything useful in the backtrace.
change include/tl/types.hpp and save it and it should crash.

You will probably need boost 1.38 as from last time.

I just downloaded your project, and will have a look into it later.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: crash while parsing source files
« Reply #21 on: April 07, 2009, 07:35:19 am »
Try the following patch and remove the comments around parent < 0 in TokenExists(...), that means revert the patch posted before:

Code
Index: src/plugins/codecompletion/parser/token.cpp
===================================================================
--- src/plugins/codecompletion/parser/token.cpp (Revision 5519)
+++ src/plugins/codecompletion/parser/token.cpp (Arbeitskopie)
@@ -598,7 +598,14 @@
     // Step 4: Remove descendants
     nodes = oldToken->m_Descendants; // Copy the list to avoid interference
     for(it = nodes.begin();it!=nodes.end(); it++)
+    {
+        if(*it == idx) // that should not happen, we can not be our own descendant, but in fact that can happen with boost
+        {
+            Manager::Get()->GetLogManager()->DebugLog(_T("Break out the loop to remove descendants, to avoid a crash. We can not be our own descendant !!"));
+            break;
+        }
         RemoveToken(*it);
+    }
     // m_Descendants SHOULD be empty by now - but clear anyway.
     oldToken->m_Descendants.clear();
 

We seem to run in an endless recursive call of RemoveToken as you can see on the call-stack if it crashes.
It tries to remove the same Token over and over (same idx).
And so most likely corrupting our memory.
Why this only happens on 64-bit, I don't know.

Offline jarro_2783

  • Multiple posting newcomer
  • *
  • Posts: 99
    • Project Freedom
Re: crash while parsing source files
« Reply #22 on: April 07, 2009, 02:05:19 pm »
it appears to work now, thanks.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: crash while parsing source files
« Reply #23 on: April 19, 2009, 02:38:23 pm »
Try the following patch and remove the comments
Try the following patch
I got another example that (Jens: as discussed) probably has the same root. Luckily it's way simpler and smaller that boost. ;-)

Attached is a project that consists just of header files. For me (on Windows) if I do:
- open any of these files
- change something (I do space + delete all the time - so I *don't* change content)
- save
- change again something like above
- save again
--> C::B crashes.

It seems probably be to be related to:
- the folder structure and the class "C" appearing in different namespaces
- the live parser...?!

Strangely it happens only at the second save to me.

[attachment deleted by admin]
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 Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: crash while parsing source files
« Reply #24 on: April 19, 2009, 02:53:40 pm »
Strangely it happens only at the second save to me.

For me it happens at first save after the parser has finished for the first time.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: crash while parsing source files
« Reply #25 on: April 19, 2009, 06:32:10 pm »
The funny thing is, that if I also log the Tokens name
Code
Manager::Get()->GetLogManager()->DebugLog(F(_T("oldToken->m_Name = %s"), oldToken->m_Name.c_str()));
I see that not always the same recursion happens.

Another thing:

how does CC decide which class is the parent-class, if no header files are explicitly included.
For example the parent class "C" that is used by CC in "M_C.h" is in the same namespace, but there are no includes, so it is not in the scope and should lead to an error when compiling.
I think that CC should only use tokens (as base class in this case) that are visible for "M_C" (in this case).
Everything else is a guess and therefore error-prone.

Offline jarro_2783

  • Multiple posting newcomer
  • *
  • Posts: 99
    • Project Freedom
Re: crash while parsing source files
« Reply #26 on: April 20, 2009, 04:26:35 pm »
I'm still getting crashes, the stack trace looks like this:

#14 0x00007f1e07a648f9 in TokensTree::RemoveToken (this=0x1307c50, oldToken=0x7f1e024715a0) at parser/token.cpp:607
#15 0x00007f1e07a648f9 in TokensTree::RemoveToken (this=0x1307c50, oldToken=0x7f1e0279e650) at parser/token.cpp:607
#16 0x00007f1e07a648f9 in TokensTree::RemoveToken (this=0x1307c50, oldToken=0x7f1e024715a0) at parser/token.cpp:607
#17 0x00007f1e07a648f9 in TokensTree::RemoveToken (this=0x1307c50, oldToken=0x7f1e0279e650) at parser/token.cpp:607
#18 0x00007f1e07a648f9 in TokensTree::RemoveToken (this=0x1307c50, oldToken=0x7f1e024715a0) at parser/token.cpp:607

Unfortunately the crash only seems to happen in my code which is now even bigger and makes it hard to track down. But notice that the values of oldToken seem to be alternating if that helps.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: crash while parsing source files
« Reply #27 on: April 20, 2009, 04:54:51 pm »
Strangely it happens only at the second save to me.

For me it happens at first save after the parser has finished for the first time.

The same to me, CB crashed after first save.

By the way, I'm not sure how to see the stack track.(windows XP)
« Last Edit: April 20, 2009, 04:57:10 pm by ollydbg »
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 jarro_2783

  • Multiple posting newcomer
  • *
  • Posts: 99
    • Project Freedom
Re: crash while parsing source files
« Reply #28 on: April 21, 2009, 12:38:27 am »
if you have mingw you can run it through gdb.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: crash while parsing source files
« Reply #29 on: April 21, 2009, 02:18:43 am »
if you have mingw you can run it through gdb.
Thank for the hint :D
I'm not sure that when Code:blocks crashes(not running in gdb), will it create a dump file in the installed directory?
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.