Bug 68528 - [Parser] Callbacks can become unbalanced on errors
Summary: [Parser] Callbacks can become unbalanced on errors
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.1   Edit
Assignee: John Camelon CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-24 14:44 EDT by Andrew Niefer CLA
Modified: 2004-08-10 13:31 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Niefer CLA 2004-06-24 14:44:08 EDT
For example, linkage specs go like this:
linkage.enterScope( requestor, astFactory.getReferenceManager() );
declaration(linkage, null, null, KeywordSetKey.DECLARATION);
linkage.exitScope( requestor, astFactory.getReferenceManager() );

if there is an exception or backtrack out of the declaration, the callback will 
never receive the exitScope, and if it keeping track of scopes it will become 
unbalanced.  

This was causing memory growth when doing large searches.
Comment 1 John Camelon CLA 2004-06-24 14:47:42 EDT
I will investigate, this may not make it into 2.0, it could be a bit risky.  
Irregardless, Search requestor should clean itself up.  
Comment 2 John Camelon CLA 2004-06-24 14:57:24 EDT
This affects any ISourceElementRequestor enter/exit callbacks.  
Comment 3 John Camelon CLA 2004-06-24 15:42:50 EDT
There's a few cases to think about: 

1.  Parse within a scope { } fails, and error handling causes us to fall 
outside of where the final '}' is: for this, we need to make the errorHandling 
aware of what type of scope it is trying to handle out of.  This will require 
the parser keeping track of {'s and }'s as we recursively decend.  

2.  Catastrophic failure requires something a bit more precise, like 
perhaps 'undoing' a previous callback.  
Comment 4 John Camelon CLA 2004-06-25 09:57:07 EDT
This cannot be fixed for 2.0.  
Setting to Future. 
Comment 5 John Camelon CLA 2004-08-03 16:09:51 EDT
Setting milestone to 2.0.l ... 
Comment 6 John Camelon CLA 2004-08-04 15:40:24 EDT
Fix has been applied to HEAD, along w/JUnit test cases to validate them.  
When we merge this with the 2.0.1 branch I shall mark the defect as resolved.
Comment 7 John Camelon CLA 2004-08-05 14:23:31 EDT
Description of Solution: 

The parser communicates to the client through a callback.  My fix uses 
Java "try{} finally{}" blocks to guarrantee that for every enter() call to the 
callback, there shall be an exit() call corresponding to it.  
Comment 8 John Camelon CLA 2004-08-10 13:31:01 EDT
The merge from HEAD to 2_0 branch is complete.  
JUnits validating these fixes have been committed to both branches. 
Marking as RESOLVED - FIXED. 
The next available 2.0.1 build shall contain these fixes along with Parser 
performance/scalability improvements.