Bug 61972 - [Scanner] Macro expansion of "#define a b(a)" causes stack overflow
Summary: [Scanner] Macro expansion of "#define a b(a)" causes stack overflow
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P2 major (vote)
Target Milestone: 2.0   Edit
Assignee: John Camelon CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 62571
  Show dependency tree
 
Reported: 2004-05-12 14:47 EDT by Mas Yokota CLA
Modified: 2004-06-04 11:04 EDT (History)
0 users

See Also:


Attachments
test case (100 bytes, text/plain)
2004-05-12 14:54 EDT, Mas Yokota CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mas Yokota CLA 2004-05-12 14:47:16 EDT
The test case below causes the stack overflow due to an infinite loop amongst 
scanner.expandDefinition()
scanner.getMacroParameters()
scanner.nextToken()
scanner.processKeywordOrIdentifier()

The test case is as follows:
#define a(i) i
#define b    a(b)
void main() { b; }
Comment 1 Mas Yokota CLA 2004-05-12 14:54:21 EDT
Created attachment 10561 [details]
test case
Comment 2 John Camelon CLA 2004-05-13 09:25:31 EDT
The problem is that subScanner's have their own context stack and thus have no 
idea about whether or not they are circularly recursing.  

As I fix this defect, I shall remove the subscanners, making the system more 
performant and scalable.  
Comment 3 John Camelon CLA 2004-06-04 11:04:55 EDT
Dave has submitted the work to remove the subscanners.  This problem is now 
fixed as a result.  JUnit test cases have been added to validate this in the 
scanner, QuickParser and CompleteParser.