Bug 68940 - Correcting C/C++ Indexer problems causes 100% cpu usage
Summary: Correcting C/C++ Indexer problems causes 100% cpu usage
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 major (vote)
Target Milestone: 2.0.1   Edit
Assignee: Andrew Niefer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-29 18:04 EDT by Joshua Pollak CLA
Modified: 2004-07-05 11:48 EDT (History)
1 user (show)

See Also:


Attachments
Causes infinite loop, 100% cpu usage (6.98 KB, application/octet-stream)
2004-06-30 13:42 EDT, Joshua Pollak CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Pollak CLA 2004-06-29 18:04:59 EDT
I have a CPP file that includes header files that cannot be found on the eclipse path. If I open this cpp 
file and correct the include line to be correct, then try to do another operation (Save, right-click for 
context menu, etc), I get 100% CPU usage and an hour glass cursor. Eclipse becomes unresponsive and 
I must kill it.

I noticed in my Eclipse settings that C/C++ Indexer was disabled in my current project settings, so the 
warning about the unlocateable header file must have come from a previous run of the indexer, before I 
disabled it. But the warning persisted.
Comment 1 John Camelon CLA 2004-06-30 10:06:32 EDT
Andrew, do you listen to preference updates and delete all the markers 
appropriately? 
Comment 2 John Camelon CLA 2004-06-30 11:28:18 EDT
Andrew has a fix that will go into the 2.0.1 stream that addresses the index 
markers not going away for you.  He found a particular case where it was 
possible that the list was not cleared.  

Regarding the 100% cpu usage - this is most likely not an Indexer issue, as 
the indexer has a timeout in case the parser gets caught in an infinite loop.  
It is either an infinite loop in the parser for the Outline View/CModel, or an 
infinite loop in the CModel's element delta calculation algorithm.  

If you can attach to the defect the piece of source that you were working with 
(or a cleaned up version, if it is proprietary) and illustrate the exact steps 
you used to reproduce the problem, I would appreciate it and then figure out 
whether or not it should gate the 2.0 release.  
Comment 3 Joshua Pollak CLA 2004-06-30 13:42:24 EDT
Created attachment 12918 [details]
Causes infinite loop, 100% cpu usage

This file causes an infinite loop and 100% cpu usage. I am not sure if the
#include'd files contribute to the problem, but I cannot attach them, there are
100s of related files and most have proprietary data. I don't know how to begin
searching for the actual cause.

Here are the steps I took that can reproduce this problem:

1) Create a new workspace
2) Create a new Managed C++ Project (Our 'normal' project is not managed, but I
was able to verify the problem happens with a managed project as well)
3) Add AdaptFeatures.cpp to the project
4) In Project Settings, add the paths to CraRacer and CraVisionKit to the
include paths. These directories contain the headers for our project-specific
libraries.
5) Open AdaptFeatures.cpp for editing.
6) Change the file in any way. I tried fixing some incorrect #include's, adding
a random comment ( /* */) and adding a space as the third character of the
first line. All three changes caused the same problem.
7) Save file (Ctrl-S, toolbar icon, whatever)

The program javaw.exe will use 100% of the CPU and Eclipse will not return.

When I restart, the modified .cpp file will not be saved, so whatever is
looping is happening before the save operation.

At this point, I tried removing the include paths from the Compiler:Directories
setting, and trying again, but it didn't seem to help. I'm not sure, because I
had to kill Eclipse, and when I returned I got an error message in the project
properties about the C++ project being from an eariler version and needing to
upgrade.

-Josh
Comment 4 Joshua Pollak CLA 2004-06-30 13:46:12 EDT
Oh, for the record:

1) I didn't write that file
2) The includes are all messed up, I noticed this bug because I was trying to 
fix them.
3) There are a few duplicate include lines:

CraVisionKit/Image/Factory.h
CraVisionKit/Util/Timer.h

are included twice. I don't know if that could be related.

-Josh
Comment 5 John Camelon CLA 2004-06-30 14:58:02 EDT
I have tried to reproduce this problem (100% looping upon any save of the 
file) using our RC2 release candidate and I do not see the behaviour you 
describe.  

I had fixed some bugs last week involving infinite loops in the parser and I 
wonder if you were using the CDT M9 build rather than RC1.  Please provide me 
with the version of Eclipse and CDT that you were using.  

Since I cannot reproduce this using the release candidate (as of yet), I'm 
going to set this to the 2.0.1 milestone.  
Comment 6 Joshua Pollak CLA 2004-06-30 15:04:37 EDT
I am using Eclipse 3.0 RC3 and CDT M9. I would be happy to upgrade to a RC of CDT to test. How do I 
do that?

I have been downloading the full archives of CDT because we have an inhouse NullSoft installer script, 
but I can try with the Eclipse updater if the RC is available that way.

-Josh
Comment 7 John Camelon CLA 2004-06-30 15:32:27 EDT
I would suggest using Eclipse 3.0 GA (available from eclipse.org site or any 
of the mirrors they provide off the download page).  

CDT RC2 is available @ 
http://download.eclipse.org/tools/cdt/updates/builds/2.0RC2 

or through the update site 
http://update.eclipse.org/tools/cdt/updates/builds/2.0RC2

Let me know if you can reproduce the problem with this build.
Thanks
Comment 8 Joshua Pollak CLA 2004-07-01 14:15:20 EDT
With Eclipse 3.0 and CDT RC2, if I modify the file, CPU usage spikes and 
Eclipse freezes for 15 seconds or so, enough time to make me nervous, but 
continues operation normally, and everything appears ok. I think whatever it is 
has been fixed.

Thanks.
Comment 9 John Camelon CLA 2004-07-05 07:46:35 EDT
Assigning defect to Andrew, then, he'll take a look @ the preference listener 
bug that he thinks you may have uncovered.  

Thanks
Comment 10 Andrew Niefer CLA 2004-07-05 11:48:09 EDT
fix has been applied to handle the disabling of the index markers at the same 
time the indexer state itself changed.
commited to HEAD and 2.0 branch