JDK-6432598 : SEGV in forte backtrace walker under collect command
  • Type: Bug
  • Component: vm-legacy
  • Sub-Component: jvmpi
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 2006-06-01
  • Updated: 2010-04-02
  • Resolved: 2006-08-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b95Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
I got a crash running JBB under the collector.
On inspection of the crash log, I found that the code in forte.cpp which validates the Lmethod of an interpreter frame is not cautious enough.

static inline bool forte_is_valid_method(methodOop method) {
  if (method == NULL || 
      // The methodOop is extracted via an offset from the current
      // interpreter frame. With AsyncGetCallTrace() the interpreter
      // frame may still be under construction so we need to make
      // sure that we got an aligned oop before we try to use it.
      !Space::is_aligned(method) ||
      !Universe::heap()->is_in_reserved((void*)method) ||
      // See if GC became active after we entered AsyncGetCallTrace()
      // and before we try to use the methodOop. This routine is
      // used in validation of the top_frame so we don't have any
      // other data to flush if we bail due to GC here.
      // Yes, there is still a window after this check and before
      // we use methodOop below, but we can't lock out GC so that
      // has to be an acceptable risk.
      Universe::heap()->is_gc_active() ||
      // klass() does not need vtable dispatch so check before is_perm()
      oop(method)->klass() != Universe::methodKlassObj() ||
      !method->is_perm() || 
      !method->is_method()) {
    return false;   // doesn't look good
  }
  return true;      // hopefully this is a method indeed
}

In the above method, the is_perm call must come before the klass check.

If not, you can get a method pointing into the unmapped part of the heap's reserved area (e.g., a very high address just within bounds), and the instruction which loads the class will SEGV.  This is what happened to me.

(You should remove the comment about a vtable, which appears to be a thoughtless and useless optimization.  Nobody cares which order the tests come in, since in most cases both tests are going to be run, since most frame collection attempts are successful.)

Comments
SUGGESTED FIX Please see the attached 6432598-webrev-cr0.tgz for the proposed fix.
27-07-2006

EVALUATION Stress testing on the Client VM shows that a minor change is needed to fix a NULL variable dereference introduced by the tiered compilation changes (6272349). See comments section for details.
26-07-2006

EVALUATION John's description pretty much says it all.
14-06-2006

WORK AROUND Well, just fire up the collector again and hope you get luckier. You probably will.
01-06-2006