comparison src/share/vm/runtime/sharedRuntime.cpp @ 3998:ec5ce9326985

6865265: JVM crashes with "missing exception handler" error Summary: Retry the call to fast_exception_handler_bci_for() after it returned with a pending exception. Don't cache the exception handler pc computed by compute_compiled_exc_handler() if the handler is for another (nested) exception. Reviewed-by: kamg, kvn Contributed-by: volker.simonis@gmail.com
author kvn
date Tue, 04 Oct 2011 14:30:04 -0700
parents 0f34fdee809e
children 23a1c8de9d51
comparison
equal deleted inserted replaced
3997:940513efe83a 3998:ec5ce9326985
657 657
658 int handler_bci = -1; 658 int handler_bci = -1;
659 int scope_depth = 0; 659 int scope_depth = 0;
660 if (!force_unwind) { 660 if (!force_unwind) {
661 int bci = sd->bci(); 661 int bci = sd->bci();
662 bool recursive_exception = false;
662 do { 663 do {
663 bool skip_scope_increment = false; 664 bool skip_scope_increment = false;
664 // exception handler lookup 665 // exception handler lookup
665 KlassHandle ek (THREAD, exception->klass()); 666 KlassHandle ek (THREAD, exception->klass());
666 handler_bci = sd->method()->fast_exception_handler_bci_for(ek, bci, THREAD); 667 handler_bci = sd->method()->fast_exception_handler_bci_for(ek, bci, THREAD);
667 if (HAS_PENDING_EXCEPTION) { 668 if (HAS_PENDING_EXCEPTION) {
669 recursive_exception = true;
668 // We threw an exception while trying to find the exception handler. 670 // We threw an exception while trying to find the exception handler.
669 // Transfer the new exception to the exception handle which will 671 // Transfer the new exception to the exception handle which will
670 // be set into thread local storage, and do another lookup for an 672 // be set into thread local storage, and do another lookup for an
671 // exception handler for this exception, this time starting at the 673 // exception handler for this exception, this time starting at the
672 // BCI of the exception handler which caused the exception to be 674 // BCI of the exception handler which caused the exception to be
678 bci = handler_bci; 680 bci = handler_bci;
679 handler_bci = -1; 681 handler_bci = -1;
680 skip_scope_increment = true; 682 skip_scope_increment = true;
681 } 683 }
682 } 684 }
685 else {
686 recursive_exception = false;
687 }
683 if (!top_frame_only && handler_bci < 0 && !skip_scope_increment) { 688 if (!top_frame_only && handler_bci < 0 && !skip_scope_increment) {
684 sd = sd->sender(); 689 sd = sd->sender();
685 if (sd != NULL) { 690 if (sd != NULL) {
686 bci = sd->bci(); 691 bci = sd->bci();
687 } 692 }
688 ++scope_depth; 693 ++scope_depth;
689 } 694 }
690 } while (!top_frame_only && handler_bci < 0 && sd != NULL); 695 } while (recursive_exception || (!top_frame_only && handler_bci < 0 && sd != NULL));
691 } 696 }
692 697
693 // found handling method => lookup exception handler 698 // found handling method => lookup exception handler
694 int catch_pco = ret_pc - nm->code_begin(); 699 int catch_pco = ret_pc - nm->code_begin();
695 700