Mercurial > hg > truffle
comparison src/share/vm/classfile/javaClasses.cpp @ 3272:01147d8aac1d
7009923: JSR 292: VM crash in JavaThread::last_frame
Summary: Handle stack overflow before the first frame is called, by printing out the called method and not walking the stack.
Reviewed-by: dholmes, phh, dsamersoff
author | coleenp |
---|---|
date | Tue, 26 Apr 2011 14:04:43 -0400 |
parents | 3449f5e02cc4 |
children | 167b70ff3abc |
comparison
equal
deleted
inserted
replaced
3271:cdd13dce903e | 3272:01147d8aac1d |
---|---|
1355 return _bcis->ushort_at(_index); | 1355 return _bcis->ushort_at(_index); |
1356 } | 1356 } |
1357 }; | 1357 }; |
1358 | 1358 |
1359 | 1359 |
1360 void java_lang_Throwable::fill_in_stack_trace(Handle throwable, TRAPS) { | 1360 void java_lang_Throwable::fill_in_stack_trace(Handle throwable, methodHandle method, TRAPS) { |
1361 if (!StackTraceInThrowable) return; | 1361 if (!StackTraceInThrowable) return; |
1362 ResourceMark rm(THREAD); | 1362 ResourceMark rm(THREAD); |
1363 | 1363 |
1364 // Start out by clearing the backtrace for this object, in case the VM | 1364 // Start out by clearing the backtrace for this object, in case the VM |
1365 // runs out of memory while allocating the stack trace | 1365 // runs out of memory while allocating the stack trace |
1371 } | 1371 } |
1372 | 1372 |
1373 int max_depth = MaxJavaStackTraceDepth; | 1373 int max_depth = MaxJavaStackTraceDepth; |
1374 JavaThread* thread = (JavaThread*)THREAD; | 1374 JavaThread* thread = (JavaThread*)THREAD; |
1375 BacktraceBuilder bt(CHECK); | 1375 BacktraceBuilder bt(CHECK); |
1376 | |
1377 // If there is no Java frame just return the method that was being called | |
1378 // with bci 0 | |
1379 if (!thread->has_last_Java_frame()) { | |
1380 if (max_depth >= 1 && method() != NULL) { | |
1381 bt.push(method(), 0, CHECK); | |
1382 set_backtrace(throwable(), bt.backtrace()); | |
1383 } | |
1384 return; | |
1385 } | |
1376 | 1386 |
1377 // Instead of using vframe directly, this version of fill_in_stack_trace | 1387 // Instead of using vframe directly, this version of fill_in_stack_trace |
1378 // basically handles everything by hand. This significantly improved the | 1388 // basically handles everything by hand. This significantly improved the |
1379 // speed of this method call up to 28.5% on Solaris sparc. 27.1% on Windows. | 1389 // speed of this method call up to 28.5% on Solaris sparc. 27.1% on Windows. |
1380 // See bug 6333838 for more details. | 1390 // See bug 6333838 for more details. |
1475 | 1485 |
1476 // Put completed stack trace into throwable object | 1486 // Put completed stack trace into throwable object |
1477 set_backtrace(throwable(), bt.backtrace()); | 1487 set_backtrace(throwable(), bt.backtrace()); |
1478 } | 1488 } |
1479 | 1489 |
1480 void java_lang_Throwable::fill_in_stack_trace(Handle throwable) { | 1490 void java_lang_Throwable::fill_in_stack_trace(Handle throwable, methodHandle method) { |
1481 // No-op if stack trace is disabled | 1491 // No-op if stack trace is disabled |
1482 if (!StackTraceInThrowable) { | 1492 if (!StackTraceInThrowable) { |
1483 return; | 1493 return; |
1484 } | 1494 } |
1485 | 1495 |
1489 } | 1499 } |
1490 | 1500 |
1491 PRESERVE_EXCEPTION_MARK; | 1501 PRESERVE_EXCEPTION_MARK; |
1492 | 1502 |
1493 JavaThread* thread = JavaThread::active(); | 1503 JavaThread* thread = JavaThread::active(); |
1494 fill_in_stack_trace(throwable, thread); | 1504 fill_in_stack_trace(throwable, method, thread); |
1495 // ignore exceptions thrown during stack trace filling | 1505 // ignore exceptions thrown during stack trace filling |
1496 CLEAR_PENDING_EXCEPTION; | 1506 CLEAR_PENDING_EXCEPTION; |
1497 } | 1507 } |
1498 | 1508 |
1499 void java_lang_Throwable::allocate_backtrace(Handle throwable, TRAPS) { | 1509 void java_lang_Throwable::allocate_backtrace(Handle throwable, TRAPS) { |