Bug 73524

Summary: CDT 2.0.1 freezes after trying to open a large .c file
Product: [Tools] CDT Reporter: Boris von Loesch <vonloesch>
Component: cdt-parserAssignee: John Camelon <john.camelon>
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: dave.daoust, khapitas, steven.wasleski
Version: 2.0   
Target Milestone: 2.0.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
After opening this file, eclipse hangs none

Description Boris von Loesch CLA 2004-09-09 05:04:30 EDT
I updated my eclipse cdt from 2.0 to 2.0.1. Updating works fine, but after the
update I have tried to open a large .c file, instead of opening the file eclipse
freezes and the processor load is at 99% (maybe endless loop). Opening other .c
or .h files works fine. In the newsgroup someone told, that he have the same
problem with a smale .c file (~ 400 lines) under linux. I am working with
eclipse 3.0 under winxp.
Comment 1 John Camelon CLA 2004-09-09 08:36:15 EDT
I need a source-code example in order to triage the defect appropriately.  
Comment 2 Boris von Loesch CLA 2004-09-09 09:46:48 EDT
Created attachment 14459 [details]
After opening this file, eclipse hangs
Comment 3 John Camelon CLA 2004-09-09 10:12:06 EDT
I see the hang. 
We need to fix this for 2.0.2.
Comment 4 John Camelon CLA 2004-09-09 14:52:57 EDT
There was a bug in the scanner that was continually creating the same token 
w/buffer length 0 over and over and chaining them together for the parser.  
This was causing the infinite loop.  

I fixed the Scanner to be more robust and protect against this.  
I also fixed the Scanner bug that started this incorrect behaviour flowing.  
We were not handling escaped newlines within strings well on Windows. (look 
for \r as well!)

I've created a JUnit to ensure this won't happen again.  
Fix applied to HEAD, AST2 & 2_0 branches.  
Comment 5 John Camelon CLA 2004-09-09 15:10:46 EDT
For Kleo: 
The code that would cause the infinite loop in the Parser/Scanner was: 

    static char fmt_1002[] = "(/,\002At iterate\002,i5,4x,\002f= \002,1p,d12\
.5,4x,\002|proj g|= \002,1p,d12.5)";

We were mishandling the escaped newline, as all newlines are \r\n on Windows.