Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 337694 - [traceview] possibility of endless loop during trace load
Summary: [traceview] possibility of endless loop during trace load
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Geclipse (show other bugs)
Version: unspecified   Edit
Hardware: PC All
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: Harald Kornmayer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-21 04:11 EST by Ansgar Radermacher CLA
Modified: 2014-01-09 16:01 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ansgar Radermacher CLA 2011-02-21 04:11:41 EST
The function getBitsForMaxValue in class AbstractTraceFileCache (in geclipse.traceview.utils) enters an endless loop, if the passed value is 0.
This happens for instance, if the trace file to open uses 0 as process ID.
Although you may consider this as a malformed file (the documentation says that the processID must be > 0), I still think this is a critical bug, since
(1) People that are new to OTF might produce such a malformed file (I did), since the restrictions are neither obvious, not checked during production
(2) The effect is disastrous, since the UI thread is blocked and you need to restart Eclipse implying a potential data loss.

final public int getBitsForMaxValue(int value) {
  int bits = 32;
  while( ( (1<<(bits-1)) & value ) == 0 || bits == 1 ) {
    bits--;
  }
  return bits;
}

should have been?
while( ( (1<<(bits-1)) & value ) == 0 && bits >= 1 ) { ...