Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 356959 - integer overflow in FSIO.cvSize leads to NegativeArraySizeException
Summary: integer overflow in FSIO.cvSize leads to NegativeArraySizeException
Status: CLOSED FIXED
Alias: None
Product: M2T
Classification: Modeling
Component: Xpand (show other bugs)
Version: 1.0.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: M3   Edit
Assignee: Karsten Thoms CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-07 11:54 EDT by Niko Stotz CLA
Modified: 2013-02-21 08:12 EST (History)
3 users (show)

See Also:
karsten.thoms: juno+


Attachments
Testcase showing the error (2.08 KB, application/octet-stream)
2011-10-07 09:50 EDT, Niko Stotz CLA
no flags Details
Proposed fixed version of FSIO (5.03 KB, text/plain)
2011-10-07 09:50 EDT, Niko Stotz CLA
sven.efftinge: iplog+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Niko Stotz CLA 2011-09-07 11:54:34 EDT
Build Identifier: 20110218-0911

The static field org.eclipse.internal.xpand2.pr.util.FSIO.cvSize is initialized with 2000 in line 31 and subsequently incremented in lines 72, 98, 135; However, it is never reset or decremented. If we run the generator with enabled ProtectedRegionResolver long/often enough, cvSize will overflow eventually. This will lead to an NegativeArraySizeException in readSingleFile(), either at line 69 or line 95.

Reproducible: Always
Comment 1 Karsten Thoms CLA 2011-09-09 11:52:21 EDT
Niko, could you propose a solution?
Comment 2 SK CLA 2011-09-09 12:19:30 EDT
writeSingleFile(Writer,Reader) in this class already states a possible solution. pick some chunksize and use it instead of doing some fancy calculation to determine a chunksize for reading.
neither cvNumerOfFilesRead nor cvSize are effectively used.
Comment 3 Niko Stotz CLA 2011-10-07 09:50:20 EDT
Created attachment 204749 [details]
Testcase showing the error
Comment 4 Niko Stotz CLA 2011-10-07 09:50:54 EDT
Created attachment 204750 [details]
Proposed fixed version of FSIO
Comment 5 Niko Stotz CLA 2011-10-07 09:51:59 EDT
The proposed fix is about 25 % faster than the original implementation.
Comment 6 Karsten Thoms CLA 2011-10-07 12:44:54 EDT
Thanks for providing the test case and fix. Had to backport the test to Junit3.
Comment 7 Karsten Thoms CLA 2013-02-21 08:12:32 EST
Bug resolved before Xpand 1.2 release date => Closing