Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 337694

Summary: [traceview] possibility of endless loop during trace load
Product: z_Archived Reporter: Ansgar Radermacher <ansgar.radermacher>
Component: GeclipseAssignee: Harald Kornmayer <harald>
Status: NEW --- QA Contact:
Severity: critical    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:

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 ) { ...