Author Topic: Crash while compiling  (Read 4652 times)

ikolev

  • Guest
Crash while compiling
« on: May 19, 2006, 11:22:30 am »
I've been using CodeBlocks for the past few months. My primary development environment is VC 2005 and I use CodeBlocks occasionally, e.g. to build my project with GCC every other day and clear any problems which the VC compiler doesn't spot (GCC is one of the most C++ standard compliant compilers, as we know).
I often get crashes (despite the occasional use). So far I just lived with them, but from now on I'll try to at least post .RPT files here, hoping that they may be fixed.
Here's the RPT from the latest crash, which happened while compiling the project:
http://www.ikolev.com/files/codeblocks.rpt.zip
A few more info about my setup:
CodeBlocks: Version 1.0 revision 2469 ()   gcc 3.4.4 Windows/unicode
(installed in a clean folder, not over some other version)
.cb project files are placed in a subfolder of the project root folder, i.e. the tree looks like
/myproj/include
/myproj/src
/myproj/proj_cb
/myproj/proj_vc80
(I mention this because some problems in the past that I reported were related to it)
The crashes are not 100% reproducible (our favorite type).
I cannot provide project/source files, the project is big and not open.

Regards,
Ivan

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Crash while compiling
« Reply #1 on: May 19, 2006, 11:51:46 am »
Did you happen (by any chance) to right-click on the project tree while compiling, and it crashed *just* then?

It is just a vague guess, since I see:
ProjectManager20OnTreeItemRightClick
ProjectManager8ShowMenu
wxWindow11DoPopupMenu

then a good two dozen wxEvtHandler12ProcessEvent, and finally... booooom.

This might be due to a wxYield() re-entrancy...

Even if the crash is not 100% reproducable, have you tried if it is entirely gone after disabling all non-vital plugins?
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

ikolev

  • Guest
Re: Crash while compiling
« Reply #2 on: May 19, 2006, 01:14:00 pm »
I think the last couple of crashes happened while C::B was building in the background, which was really surprising to me. Until now I had crashes when middle-clicking on a tab to close some file while building, so I had become careful not to touch the IDE too much while it's compiling. Not sure about right-clicking in the project tree.
As for the plugins - I don't need most of them so I'll disable what I can.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Crash while compiling
« Reply #3 on: May 19, 2006, 02:23:18 pm »
Until now I had crashes when middle-clicking on a tab to close some file while building
Aha, that does not explain ProjectManager20OnTreeItemRightClick, but it hardens the theory of a wxYield re-entrancy.

For example, the DevPak plugin uses wxYield in several places.
Worse yet, wxWidgets sometimes calls wxYield secretly, too!

This line from the code completion plugin:
  wxExecute(Command, Output, Errors, wxEXEC_NODISABLE);
is a very good candidate for the origin of the crash (especially due to wxEXEC_NODISABLE).

The same construct appears in a couple of other places, too (for example in CompilerCommandGenerator::ExpandBackticks).

Unluckily, the solution is not easy, because wxExecute sucks so bad. If you call wxExecute synchronously, it will run a tight loop around wxYield, waiting for the pipe to close. This means that the user interface (which runs in the same thread) stays responsive, but at the same time, it means that any other call to wxYield will crash you if you click a mouse button or anything.
The "solution" to this problem is to simply disable the application window during that time (unless you provide the wxEXEC_NODISABLE flag).

So basically, you can choose whether you want to risk a crash or whether you prefer your app window changing state all the time and your application hanging dead in space for as long as the background job is running...

A solution that works reliably is to always call wxExecute asynchronously and send the output via the event handler, but that is quite inefficient, and not easy in every case. In some situations, it may even not be possible at all. For example, how would you do such an awkward thing during backticks expansion.

I hope that we can get away by tweaking the DevPak plugin, though. I don't have that plugin installed here, and I never see a crash, so with some luck, we can replace all those wxYields, and it will fix your problem (one wxYield at a time is not obnoxious).
First, however, it would be interesting to know whether deactivating plugins (particularly that one EDIT: and code completion) really helps. If that doesn't change anything, then it isn't worthwile to look in that place ;)
« Last Edit: May 19, 2006, 03:22:54 pm by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Crash while compiling
« Reply #4 on: May 19, 2006, 06:19:22 pm »
Quote
This line from the code completion plugin:

Unless something is utterly wrong, this line executes only on program startup so it can't be the cause...
Be patient!
This bug will be fixed soon...