Author Topic: CodeCompletion freezes C::B after project drag'n drop  (Read 11053 times)

Offline christobal

  • Multiple posting newcomer
  • *
  • Posts: 41
CodeCompletion freezes C::B after project drag'n drop
« on: January 16, 2012, 05:11:13 pm »
Recently, I have problems loading projects via drag and drop to the workspace. At first it looks like Code::Blocks loads the project just fine (the project is shown in the workspace tree and marked as active project), but then Code::Blocks freezes.

After some research I could find out, that the DoFullParsing routine doesn't exit when a new Parser is created during the "OnProjectActivated" event. It seems that the loop, which handles the parsing of the priority_files does never exit (nativeparser.cpp line ~1400).

It looks to me like some kind of race condition, because the problem only arises when:
1. no other project has been loaded before
2. the project exceeds a certain size (maybe filenumber, option settings etc. I can't really tell...)

If a project is loaded from the "recent project list", everything works just fine.

How to reproduce:
1. Start Code::Blocks (Win32 svn rev. 7694)
2. Drag and Drop the CodeBlocks.cbp file to the empty Default Workspace

Can anyone confirm this?

Offline AndyJ

  • Multiple posting newcomer
  • *
  • Posts: 24
Re: CodeCompletion freezes C::B after project drag'n drop
« Reply #1 on: January 16, 2012, 05:37:07 pm »
I've seen this quite often going back some while now. I even reported it here:

http://forums.codeblocks.org/index.php/topic,13766.msg95051.html#msg95051

Andy

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: CodeCompletion freezes C::B after project drag'n drop
« Reply #2 on: January 16, 2012, 08:03:23 pm »
How to reproduce:
1. Start Code::Blocks (Win32 svn rev. 7694)
2. Drag and Drop the CodeBlocks.cbp file to the empty Default Workspace
http://forums.codeblocks.org/index.php/topic,13766.msg95051.html#msg95051
I cannot confirm both, this is just working fine for me on Windows. I tried several times, re-starting C::B in between. I even tried with a complete C::B workspace, so having ~80 projects, including the core project.
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: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: CodeCompletion freezes C::B after project drag'n drop
« Reply #3 on: January 17, 2012, 02:20:31 am »
Recently, I have problems loading projects via drag and drop to the workspace. At first it looks like Code::Blocks loads the project just fine (the project is shown in the workspace tree and marked as active project), but then Code::Blocks freezes.

Sometimes, My C::B hangs when loading a large project. But it has a very low happening rate, maybe 1%.

Quote
After some research I could find out, that the DoFullParsing routine doesn't exit when a new Parser is created during the "OnProjectActivated" event. It seems that the loop, which handles the parsing of the priority_files does never exit (nativeparser.cpp line ~1400).
DoFullParsing() function just prepare a full parsing (the function name "DoFullParsing" it not quite good I think), it add many thread tasks, and real parsing is done in other working threads. So, I think there are some bugs, but those bugs are hard to track. I don't think we have a good way to debug all the parsing threads.
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 christobal

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: CodeCompletion freezes C::B after project drag'n drop
« Reply #4 on: January 17, 2012, 11:23:02 am »
I solved my problem by renaming default.conf and let Code::Blocks create a new one. The old file has grown over the years up to roughly 550 kB :o. After that I started to play with my old one to figure out which entry made Code::Blocks misbehave, but I couldn't detect any entry in particular. It seems to me that the whole plugin loading process is getting unstable if a certain amount of data has to be loaded from the default.conf.

I figured that the Header Fixup plugin is responsible for about 75% of the default.conf data. The project loading worked again after I removed the <HeaderFixup> section in the default.conf. Alternatively the deactivation of the plugin did also work. I will deactivate it for now because I have no use for it anyway...

This workaround is of course no solution, but maybe you could figure out what's wrong. I'm happy to test any patches.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: CodeCompletion freezes C::B after project drag'n drop
« Reply #5 on: January 17, 2012, 12:57:20 pm »
I figured that the Header Fixup plugin is responsible for about 75% of the default.conf data. The project loading worked again after I removed the <HeaderFixup> section in the default.conf. Alternatively the deactivation of the plugin did also work. I will deactivate it for now because I have no use for it anyway...
I saw that, to. The plugin is missing a "dirty" flag to only store data that has been changed. For now, it always saves all data the time you press the configuration dialog with "OK".

However, this is transparent to the rest of C::B and won't hurt. ConfigManager in C::B can handle way more configuration data than that. So besides it's not "nice" it is not an issue.
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 christobal

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: CodeCompletion freezes C::B after project drag'n drop
« Reply #6 on: January 17, 2012, 05:37:06 pm »
Quote
However, this is transparent to the rest of C::B and won't hurt. ConfigManager in C::B can handle way more configuration data than that. So besides it's not "nice" it is not an issue.

ConfigManager can certainly handle more data, but it seems somehow to be related with the application crash I encountered.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: CodeCompletion freezes C::B after project drag'n drop
« Reply #7 on: January 17, 2012, 06:21:52 pm »
Quote
However, this is transparent to the rest of C::B and won't hurt. ConfigManager in C::B can handle way more configuration data than that. So besides it's not "nice" it is not an issue.

ConfigManager can certainly handle more data, but it seems somehow to be related with the application crash I encountered.
Have you backed up the faulty conf-file ?
If yes, is it possible to send it to me via mail ?

my_nickname a t codeblocks.org or use the email-address you can find on my server (see signature) in the footline.

Offline christobal

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: CodeCompletion freezes C::B when a project is opened or closed
« Reply #8 on: January 20, 2012, 10:46:40 am »
Quote
Have you backed up the faulty conf-file ?
If yes, is it possible to send it to me via mail ?
I've sent it to you but the error doesn't show up every time,  so you might need to open and close Code::Blocks and the project several times. BTW: closing the project seems to be as problematic as opening it and it doesn't matter whether the project has been opend using the Recent Projects List or by a drag'n drop.

Meanwhile I've tested several revisions and found out, that the first open/close errors came up with the changes in Rev. 7419. After that, the behaviour gets somewhat better or worse during the revisions (sometimes closing a project doesn't freeze Code::Blocks but takes significantly longer than usual) but it never got back to a state that was stable.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: CodeCompletion freezes C::B when a project is opened or closed
« Reply #9 on: January 20, 2012, 02:52:44 pm »
Meanwhile I've tested several revisions and found out, that the first open/close errors came up with the changes in Rev. 7419. After that, the behaviour gets somewhat better or worse during the revisions (sometimes closing a project doesn't freeze Code::Blocks but takes significantly longer than usual) but it never got back to a state that was stable.
That revision rewrite the locker in many files, I guess there are some dead locks.
Code
Revision: 7419
Author: loaden
Date: 2011-8-26 14:09:39
Message:
* CC: Rewrite thread lock of TokensTree again
-------------------------------
M : /trunk/src/plugins/codecompletion/ccdebuginfo.cpp

M : /trunk/src/plugins/codecompletion/classbrowser.cpp

M : /trunk/src/plugins/codecompletion/classbrowserbuilderthread.cpp

M : /trunk/src/plugins/codecompletion/classbrowserbuilderthread.h

M : /trunk/src/plugins/codecompletion/codecompletion.cpp

M : /trunk/src/plugins/codecompletion/insertclassmethoddlg.cpp

M : /trunk/src/plugins/codecompletion/insertclassmethoddlg.h

M : /trunk/src/plugins/codecompletion/nativeparser.cpp

M : /trunk/src/plugins/codecompletion/nativeparser.h

M : /trunk/src/plugins/codecompletion/parser/parser.cpp

M : /trunk/src/plugins/codecompletion/parser/parser.h

M : /trunk/src/plugins/codecompletion/parser/parserdummy.cpp

M : /trunk/src/plugins/codecompletion/parser/parserthread.cpp

M : /trunk/src/plugins/codecompletion/parser/parserthread.h

M : /trunk/src/plugins/codecompletion/parser/token.h

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: CodeCompletion freezes C::B when a project is opened or closed
« Reply #10 on: January 20, 2012, 03:05:34 pm »
That revision rewrite the locker in many files, I guess there are some dead locks.
Either that, or (in combination) could you check if you have enabled "parse while typing" in the CC settings? If so, turn it off and try again. I experienced some issues with that feature recently - probably we should remove it or at least disable it by default.
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: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: CodeCompletion freezes C::B when a project is opened or closed
« Reply #11 on: January 20, 2012, 03:23:52 pm »
That revision rewrite the locker in many files, I guess there are some dead locks.
Either that, or (in combination) could you check if you have enabled "parse while typing" in the CC settings? If so, turn it off and try again. I experienced some issues with that feature recently - probably we should remove it or at least disable it by default.
Enabled "parse while typing" is always ON in my c::b, sometimes, c::b hangs for a while(1 second maybe) after I enter some characters. Did you have such issue?

I have no idea to catch such issue. I'm thinking that the lockers should be removed totally.
The new method looks like:
The thread Pool can have a function: Pause and Resume. When we pause it, it just finish the currently running thread, and no new thread should be started. When we resume it, it can continue running.

So, we can do some UI related work when we pause the parserthread pool. This way, we can remove all the lockers. There is an assumption that one parserthread should no taking too long time to finish its parsing work.
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: 13413
    • Travis build status
Re: CodeCompletion freezes C::B when a project is opened or closed
« Reply #12 on: January 20, 2012, 04:15:26 pm »
The thread Pool can have a function: Pause and Resume. When we pause it, it just finish the currently running thread, and no new thread should be started. When we resume it, it can continue running.
Please don't waste time on such a scheme, because it will fail pretty miserably.
(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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: CodeCompletion freezes C::B when a project is opened or closed
« Reply #13 on: January 21, 2012, 08:15:59 am »
The thread Pool can have a function: Pause and Resume. When we pause it, it just finish the currently running thread, and no new thread should be started. When we resume it, it can continue running.
Please don't waste time on such a scheme, because it will fail pretty miserably.
Ok, but can we have a better scheme then current "many locker" scheme?
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: 13413
    • Travis build status
Re: CodeCompletion freezes C::B after project drag'n drop
« Reply #14 on: January 21, 2012, 08:42:50 am »
I don't know.
(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!]