Thu, 22 Dec 2016 15:55:08 -0800
Merge
.hgtags | file | annotate | diff | comparison | revisions |
1.1 --- a/.hgtags Tue Dec 20 15:36:08 2016 -0800 1.2 +++ b/.hgtags Thu Dec 22 15:55:08 2016 -0800 1.3 @@ -895,6 +895,10 @@ 1.4 f6daf04c0f48dab5420ad63d21da82a7fa4e3ad7 jdk8u102-b13 1.5 ac29c9c1193aef5d480b200ed94c5d579243c17b jdk8u102-b14 1.6 96e1c72fc617d3c6c125bcfc9182f77fc6aa38e6 jdk8u102-b31 1.7 +c8988d2e4212583ec0f04591c8e241ad3cf95674 jdk8u102-b32 1.8 +9050d85e29600400ce4ba2b4db9616388082ae08 jdk8u102-b33 1.9 +b678b66d1538af31bac7cf5e74c029395607decd jdk8u102-b34 1.10 +8a2db0a6c499250050b59f9a47acd9ea80de92c2 jdk8u102-b35 1.11 ceecf88e5c2c09bfabf5926581e6d0b0f65f5148 jdk8u111-b00 1.12 e73d79ce00e4a0451e464c7a73d9c911d01e169a jdk8u111-b01 1.13 d584a614818562e1187e1a15c202aec01491caeb jdk8u111-b02 1.14 @@ -926,6 +930,21 @@ 1.15 c2c4db2a42a215c98a4f027edb8bbb00dd62d9b9 jdk8u112-b14 1.16 b28d012a24cab8f4ceeee0c9d3252969757423ed jdk8u112-b15 1.17 e134dc1879b72124e478be01680b0646a2fbf585 jdk8u112-b16 1.18 +87440ed4e1de7753a436f957d35555d8b4e26f1d jdk8u112-b31 1.19 +3b0e5f01891f5ebbf67797b1aae786196f1bb4f6 jdk8u121-b00 1.20 +251a2493b1857f2ff4f11eab2dfd8b2fe8ed441b jdk8u121-b01 1.21 +70c4a50f576a01ec975d0a02b3642ee33db39ed8 jdk8u121-b02 1.22 +fa3bb4153a28b45a7a80cbf1058979b8f1c8b104 jdk8u121-b03 1.23 +35cff8508ca15dc18c598501cab160aee7220d44 jdk8u121-b04 1.24 +f71447f104ce7b018a08bf1cf385438525744d13 jdk8u121-b05 1.25 +49a2fc91c46f3d73aac7dbd420a4a007fe453ef8 jdk8u121-b06 1.26 +f31c7533cfcb55acfb8dc5b31779d3a64708f5ce jdk8u121-b07 1.27 +02a3d0dcbeddd8507d9a4b1f5a9f83aca75e5acb jdk8u121-b08 1.28 +8cae1bdbd73cb1a84afad07a8e18467f56560bc4 jdk8u121-b09 1.29 +f26f6895c9dfb32dfb4c228d69b371d8ab118536 jdk8u121-b10 1.30 +11f91811e4d7e5ddfaf938dcf386ec8fe5bf7b7c jdk8u121-b11 1.31 +b132b08b28bf23a26329928cf6b4ffda5857f4d3 jdk8u121-b12 1.32 +90f94521c3515e5f27af0ab9b31d036e88bb322a jdk8u121-b13 1.33 5aa8c4ca51f0e666d368a4f119ed734d3ac59d7c jdk8u122-b00 1.34 2198ef7e1c1702b3506b95b5d8c886ad5a12bbe5 jdk8u122-b01 1.35 58d961f47dd4ee1d516512b7744e0f1fc83d8f52 jdk8u122-b02
2.1 --- a/src/share/vm/classfile/classFileParser.cpp Tue Dec 20 15:36:08 2016 -0800 2.2 +++ b/src/share/vm/classfile/classFileParser.cpp Thu Dec 22 15:55:08 2016 -0800 2.3 @@ -944,11 +944,12 @@ 2.4 runtime_visible_annotations_length = attribute_length; 2.5 runtime_visible_annotations = cfs->get_u1_buffer(); 2.6 assert(runtime_visible_annotations != NULL, "null visible annotations"); 2.7 + cfs->guarantee_more(runtime_visible_annotations_length, CHECK); 2.8 parse_annotations(runtime_visible_annotations, 2.9 runtime_visible_annotations_length, 2.10 parsed_annotations, 2.11 CHECK); 2.12 - cfs->skip_u1(runtime_visible_annotations_length, CHECK); 2.13 + cfs->skip_u1_fast(runtime_visible_annotations_length); 2.14 } else if (PreserveAllAnnotations && attribute_name == vmSymbols::tag_runtime_invisible_annotations()) { 2.15 runtime_invisible_annotations_length = attribute_length; 2.16 runtime_invisible_annotations = cfs->get_u1_buffer(); 2.17 @@ -1655,6 +1656,11 @@ 2.18 return index; 2.19 } 2.20 2.21 +// Safely increment index by val if does not pass limit 2.22 +#define SAFE_ADD(index, limit, val) \ 2.23 +if (index >= limit - val) return limit; \ 2.24 +index += val; 2.25 + 2.26 // Skip an annotation value. Return >=limit if there is any problem. 2.27 int ClassFileParser::skip_annotation_value(u1* buffer, int limit, int index) { 2.28 // value := switch (tag:u1) { 2.29 @@ -1665,19 +1671,19 @@ 2.30 // case @: annotation; 2.31 // case s: s_con:u2; 2.32 // } 2.33 - if ((index += 1) >= limit) return limit; // read tag 2.34 + SAFE_ADD(index, limit, 1); // read tag 2.35 u1 tag = buffer[index-1]; 2.36 switch (tag) { 2.37 case 'B': case 'C': case 'I': case 'S': case 'Z': 2.38 case 'D': case 'F': case 'J': case 'c': case 's': 2.39 - index += 2; // skip con or s_con 2.40 + SAFE_ADD(index, limit, 2); // skip con or s_con 2.41 break; 2.42 case 'e': 2.43 - index += 4; // skip e_class, e_name 2.44 + SAFE_ADD(index, limit, 4); // skip e_class, e_name 2.45 break; 2.46 case '[': 2.47 { 2.48 - if ((index += 2) >= limit) return limit; // read nval 2.49 + SAFE_ADD(index, limit, 2); // read nval 2.50 int nval = Bytes::get_Java_u2(buffer+index-2); 2.51 while (--nval >= 0 && index < limit) { 2.52 index = skip_annotation_value(buffer, limit, index); 2.53 @@ -1699,8 +1705,8 @@ 2.54 ClassFileParser::AnnotationCollector* coll, 2.55 TRAPS) { 2.56 // annotations := do(nann:u2) {annotation} 2.57 - int index = 0; 2.58 - if ((index += 2) >= limit) return; // read nann 2.59 + int index = 2; 2.60 + if (index >= limit) return; // read nann 2.61 int nann = Bytes::get_Java_u2(buffer+index-2); 2.62 enum { // initial annotation layout 2.63 atype_off = 0, // utf8 such as 'Ljava/lang/annotation/Retention;' 2.64 @@ -1719,7 +1725,8 @@ 2.65 s_size = 9, 2.66 min_size = 6 // smallest possible size (zero members) 2.67 }; 2.68 - while ((--nann) >= 0 && (index-2 + min_size <= limit)) { 2.69 + // Cannot add min_size to index in case of overflow MAX_INT 2.70 + while ((--nann) >= 0 && (index-2 <= limit - min_size)) { 2.71 int index0 = index; 2.72 index = skip_annotation(buffer, limit, index); 2.73 u1* abase = buffer + index0; 2.74 @@ -2324,10 +2331,11 @@ 2.75 runtime_visible_annotations_length = method_attribute_length; 2.76 runtime_visible_annotations = cfs->get_u1_buffer(); 2.77 assert(runtime_visible_annotations != NULL, "null visible annotations"); 2.78 + cfs->guarantee_more(runtime_visible_annotations_length, CHECK_(nullHandle)); 2.79 parse_annotations(runtime_visible_annotations, 2.80 runtime_visible_annotations_length, &parsed_annotations, 2.81 CHECK_(nullHandle)); 2.82 - cfs->skip_u1(runtime_visible_annotations_length, CHECK_(nullHandle)); 2.83 + cfs->skip_u1_fast(runtime_visible_annotations_length); 2.84 } else if (PreserveAllAnnotations && method_attribute_name == vmSymbols::tag_runtime_invisible_annotations()) { 2.85 runtime_invisible_annotations_length = method_attribute_length; 2.86 runtime_invisible_annotations = cfs->get_u1_buffer(); 2.87 @@ -2953,11 +2961,12 @@ 2.88 runtime_visible_annotations_length = attribute_length; 2.89 runtime_visible_annotations = cfs->get_u1_buffer(); 2.90 assert(runtime_visible_annotations != NULL, "null visible annotations"); 2.91 + cfs->guarantee_more(runtime_visible_annotations_length, CHECK); 2.92 parse_annotations(runtime_visible_annotations, 2.93 runtime_visible_annotations_length, 2.94 parsed_annotations, 2.95 CHECK); 2.96 - cfs->skip_u1(runtime_visible_annotations_length, CHECK); 2.97 + cfs->skip_u1_fast(runtime_visible_annotations_length); 2.98 } else if (PreserveAllAnnotations && tag == vmSymbols::tag_runtime_invisible_annotations()) { 2.99 runtime_invisible_annotations_length = attribute_length; 2.100 runtime_invisible_annotations = cfs->get_u1_buffer();
3.1 --- a/src/share/vm/classfile/stackMapFrame.cpp Tue Dec 20 15:36:08 2016 -0800 3.2 +++ b/src/share/vm/classfile/stackMapFrame.cpp Thu Dec 22 15:55:08 2016 -0800 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -155,47 +155,8 @@ 3.11 return i; 3.12 } 3.13 3.14 -bool StackMapFrame::has_flag_match_exception( 3.15 - const StackMapFrame* target) const { 3.16 - // We allow flags of {UninitThis} to assign to {} if-and-only-if the 3.17 - // target frame does not depend upon the current type. 3.18 - // This is slightly too strict, as we need only enforce that the 3.19 - // slots that were initialized by the <init> (the things that were 3.20 - // UninitializedThis before initialize_object() converted them) are unused. 3.21 - // However we didn't save that information so we'll enforce this upon 3.22 - // anything that might have been initialized. This is a rare situation 3.23 - // and javac never generates code that would end up here, but some profilers 3.24 - // (such as NetBeans) might, when adding exception handlers in <init> 3.25 - // methods to cover the invokespecial instruction. See 7020118. 3.26 - 3.27 - assert(max_locals() == target->max_locals() && 3.28 - stack_size() == target->stack_size(), "StackMap sizes must match"); 3.29 - 3.30 - VerificationType top = VerificationType::top_type(); 3.31 - VerificationType this_type = verifier()->current_type(); 3.32 - 3.33 - if (!flag_this_uninit() || target->flags() != 0) { 3.34 - return false; 3.35 - } 3.36 - 3.37 - for (int i = 0; i < target->locals_size(); ++i) { 3.38 - if (locals()[i] == this_type && target->locals()[i] != top) { 3.39 - return false; 3.40 - } 3.41 - } 3.42 - 3.43 - for (int i = 0; i < target->stack_size(); ++i) { 3.44 - if (stack()[i] == this_type && target->stack()[i] != top) { 3.45 - return false; 3.46 - } 3.47 - } 3.48 - 3.49 - return true; 3.50 -} 3.51 - 3.52 bool StackMapFrame::is_assignable_to( 3.53 - const StackMapFrame* target, bool is_exception_handler, 3.54 - ErrorContext* ctx, TRAPS) const { 3.55 + const StackMapFrame* target, ErrorContext* ctx, TRAPS) const { 3.56 if (_max_locals != target->max_locals()) { 3.57 *ctx = ErrorContext::locals_size_mismatch( 3.58 _offset, (StackMapFrame*)this, (StackMapFrame*)target); 3.59 @@ -226,8 +187,7 @@ 3.60 return false; 3.61 } 3.62 3.63 - bool match_flags = (_flags | target->flags()) == target->flags(); 3.64 - if (match_flags || is_exception_handler && has_flag_match_exception(target)) { 3.65 + if ((_flags | target->flags()) == target->flags()) { 3.66 return true; 3.67 } else { 3.68 *ctx = ErrorContext::bad_flags(target->offset(),
4.1 --- a/src/share/vm/classfile/stackMapFrame.hpp Tue Dec 20 15:36:08 2016 -0800 4.2 +++ b/src/share/vm/classfile/stackMapFrame.hpp Thu Dec 22 15:55:08 2016 -0800 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -167,8 +167,7 @@ 4.11 4.12 // Return true if this stack map frame is assignable to target. 4.13 bool is_assignable_to( 4.14 - const StackMapFrame* target, bool is_exception_handler, 4.15 - ErrorContext* ctx, TRAPS) const; 4.16 + const StackMapFrame* target, ErrorContext* ctx, TRAPS) const; 4.17 4.18 inline void set_mark() { 4.19 #ifdef ASSERT 4.20 @@ -290,8 +289,6 @@ 4.21 int is_assignable_to( 4.22 VerificationType* src, VerificationType* target, int32_t len, TRAPS) const; 4.23 4.24 - bool has_flag_match_exception(const StackMapFrame* target) const; 4.25 - 4.26 TypeOrigin stack_top_ctx(); 4.27 4.28 void print_on(outputStream* str) const;
5.1 --- a/src/share/vm/classfile/stackMapTable.cpp Tue Dec 20 15:36:08 2016 -0800 5.2 +++ b/src/share/vm/classfile/stackMapTable.cpp Thu Dec 22 15:55:08 2016 -0800 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. 5.6 + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 * This code is free software; you can redistribute it and/or modify it 5.10 @@ -70,26 +70,25 @@ 5.11 5.12 bool StackMapTable::match_stackmap( 5.13 StackMapFrame* frame, int32_t target, 5.14 - bool match, bool update, bool handler, ErrorContext* ctx, TRAPS) const { 5.15 + bool match, bool update, ErrorContext* ctx, TRAPS) const { 5.16 int index = get_index_from_offset(target); 5.17 - return match_stackmap(frame, target, index, match, update, handler, ctx, THREAD); 5.18 + return match_stackmap(frame, target, index, match, update, ctx, THREAD); 5.19 } 5.20 5.21 // Match and/or update current_frame to the frame in stackmap table with 5.22 // specified offset and frame index. Return true if the two frames match. 5.23 -// handler is true if the frame in stackmap_table is for an exception handler. 5.24 // 5.25 -// The values of match and update are: _match__update__handler 5.26 +// The values of match and update are: _match__update 5.27 // 5.28 -// checking a branch target: true false false 5.29 -// checking an exception handler: true false true 5.30 +// checking a branch target: true false 5.31 +// checking an exception handler: true false 5.32 // linear bytecode verification following an 5.33 -// unconditional branch: false true false 5.34 +// unconditional branch: false true 5.35 // linear bytecode verification not following an 5.36 -// unconditional branch: true true false 5.37 +// unconditional branch: true true 5.38 bool StackMapTable::match_stackmap( 5.39 StackMapFrame* frame, int32_t target, int32_t frame_index, 5.40 - bool match, bool update, bool handler, ErrorContext* ctx, TRAPS) const { 5.41 + bool match, bool update, ErrorContext* ctx, TRAPS) const { 5.42 if (frame_index < 0 || frame_index >= _frame_count) { 5.43 *ctx = ErrorContext::missing_stackmap(frame->offset()); 5.44 frame->verifier()->verify_error( 5.45 @@ -102,7 +101,7 @@ 5.46 if (match) { 5.47 // Has direct control flow from last instruction, need to match the two 5.48 // frames. 5.49 - result = frame->is_assignable_to(stackmap_frame, handler, 5.50 + result = frame->is_assignable_to(stackmap_frame, 5.51 ctx, CHECK_VERIFY_(frame->verifier(), result)); 5.52 } 5.53 if (update) { 5.54 @@ -126,7 +125,7 @@ 5.55 StackMapFrame* frame, int32_t target, TRAPS) const { 5.56 ErrorContext ctx; 5.57 bool match = match_stackmap( 5.58 - frame, target, true, false, false, &ctx, CHECK_VERIFY(frame->verifier())); 5.59 + frame, target, true, false, &ctx, CHECK_VERIFY(frame->verifier())); 5.60 if (!match || (target < 0 || target >= _code_length)) { 5.61 frame->verifier()->verify_error(ctx, 5.62 "Inconsistent stackmap frames at branch target %d", target);
6.1 --- a/src/share/vm/classfile/stackMapTable.hpp Tue Dec 20 15:36:08 2016 -0800 6.2 +++ b/src/share/vm/classfile/stackMapTable.hpp Thu Dec 22 15:55:08 2016 -0800 6.3 @@ -1,5 +1,5 @@ 6.4 /* 6.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 6.6 + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. 6.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.8 * 6.9 * This code is free software; you can redistribute it and/or modify it 6.10 @@ -74,12 +74,12 @@ 6.11 // specified offset. Return true if the two frames match. 6.12 bool match_stackmap( 6.13 StackMapFrame* current_frame, int32_t offset, 6.14 - bool match, bool update, bool handler, ErrorContext* ctx, TRAPS) const; 6.15 + bool match, bool update, ErrorContext* ctx, TRAPS) const; 6.16 // Match and/or update current_frame to the frame in stackmap table with 6.17 // specified offset and frame index. Return true if the two frames match. 6.18 bool match_stackmap( 6.19 StackMapFrame* current_frame, int32_t offset, int32_t frame_index, 6.20 - bool match, bool update, bool handler, ErrorContext* ctx, TRAPS) const; 6.21 + bool match, bool update, ErrorContext* ctx, TRAPS) const; 6.22 6.23 // Check jump instructions. Make sure there are no uninitialized 6.24 // instances on backward branch.
7.1 --- a/src/share/vm/classfile/verifier.cpp Tue Dec 20 15:36:08 2016 -0800 7.2 +++ b/src/share/vm/classfile/verifier.cpp Thu Dec 22 15:55:08 2016 -0800 7.3 @@ -504,19 +504,13 @@ 7.4 stack_map_frame* sm_frame = sm_table->entries(); 7.5 streamIndentor si2(ss); 7.6 int current_offset = -1; 7.7 - // Subtract two from StackMapAttribute length because the length includes 7.8 - // two bytes for number of table entries. 7.9 - size_t sm_table_space = method->stackmap_data()->length() - 2; 7.10 + address end_of_sm_table = (address)sm_table + method->stackmap_data()->length(); 7.11 for (u2 i = 0; i < sm_table->number_of_entries(); ++i) { 7.12 ss->indent(); 7.13 - size_t sm_frame_size = sm_frame->size(); 7.14 - // If the size of the next stackmap exceeds the length of the entire 7.15 - // stackmap table then print a truncated message and return. 7.16 - if (sm_frame_size > sm_table_space) { 7.17 + if (!sm_frame->verify((address)sm_frame, end_of_sm_table)) { 7.18 sm_frame->print_truncated(ss, current_offset); 7.19 return; 7.20 } 7.21 - sm_table_space -= sm_frame_size; 7.22 sm_frame->print_on(ss, current_offset); 7.23 ss->cr(); 7.24 current_offset += sm_frame->offset_delta(); 7.25 @@ -1820,7 +1814,7 @@ 7.26 // If matched, current_frame will be updated by this method. 7.27 bool matches = stackmap_table->match_stackmap( 7.28 current_frame, this_offset, stackmap_index, 7.29 - !no_control_flow, true, false, &ctx, CHECK_VERIFY_(this, 0)); 7.30 + !no_control_flow, true, &ctx, CHECK_VERIFY_(this, 0)); 7.31 if (!matches) { 7.32 // report type error 7.33 verify_error(ctx, "Instruction type does not match stack map"); 7.34 @@ -1867,7 +1861,7 @@ 7.35 } 7.36 ErrorContext ctx; 7.37 bool matches = stackmap_table->match_stackmap( 7.38 - new_frame, handler_pc, true, false, true, &ctx, CHECK_VERIFY(this)); 7.39 + new_frame, handler_pc, true, false, &ctx, CHECK_VERIFY(this)); 7.40 if (!matches) { 7.41 verify_error(ctx, "Stack map does not match the one at " 7.42 "exception handler %d", handler_pc);
8.1 --- a/test/runtime/handlerInTry/LoadHandlerInTry.java Tue Dec 20 15:36:08 2016 -0800 8.2 +++ b/test/runtime/handlerInTry/LoadHandlerInTry.java Thu Dec 22 15:55:08 2016 -0800 8.3 @@ -1,5 +1,5 @@ 8.4 /* 8.5 - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 8.6 + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. 8.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.8 * 8.9 * This code is free software; you can redistribute it and/or modify it 8.10 @@ -24,7 +24,7 @@ 8.11 /* 8.12 * @test 8.13 * @bug 8075118 8.14 - * @summary Allow a ctor to call super() from a switch bytecode. 8.15 + * @summary JVM stuck in infinite loop during verification 8.16 * @compile HandlerInTry.jasm 8.17 * @compile IsolatedHandlerInTry.jasm 8.18 * @run main/othervm -Xverify:all LoadHandlerInTry 8.19 @@ -70,9 +70,10 @@ 8.20 System.out.println("Regression test for bug 8075118"); 8.21 try { 8.22 Class newClass = Class.forName("HandlerInTry"); 8.23 - } catch (Exception e) { 8.24 - System.out.println("Failed: Exception was thrown: " + e.toString()); 8.25 - throw e; 8.26 + throw new RuntimeException( 8.27 + "Failed to throw VerifyError for HandlerInTry"); 8.28 + } catch (java.lang.VerifyError e) { 8.29 + System.out.println("Passed: VerifyError exception was thrown"); 8.30 } 8.31 8.32 try {