-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
P4
-
Affects Version/s: repo-valhalla
-
Component/s: core-libs
StrictInstanceFieldTest.java has a variety of positive test cases written in Java that use @StrictInit so that the ACC_STRICT_INIT flag can be applied by the StrictProcessor. One positive test case, TryCatchChild, fails verification with the error below:
TEST RESULT: Failed. Execution failed: `main' threw exception: java.lang.VerifyError: Stack map does not match the one at exception handler 31 Exception Details: Location: TryCatchChild2.<init>()V @31: astore_1 Reason: Current frame's strict instance fields not compatible with stackmap. Current Frame: bci: @0 flags: { flagThisUninit } locals: { uninitializedThis } stack: { 'java/lang/ArrayIndexOutOfBoundsException' } Stackmap Frame: bci: @31 flags: { flagThisUninit } locals: { uninitializedThis } stack: { 'java/lang/ArrayIndexOutOfBoundsException' } Bytecode: 0000000: 2a03 b500 0104 bc0a 4cb2 0007 2b05 2eb6 0000010: 000d 2a2a 045a b500 13b5 0001 a700 234c 0000020: 2a03 b500 132a 2a04 5ab5 0013 b500 01a7 0000030: 0010 4d2a 2a04 5ab5 0013 b500 012c bf2a 0000040: b700 18b1 Exception Handler Table: bci [0, 18] => handler: 31 bci [0, 18] => handler: 50 bci [31, 37] => handler: 50 Stackmap Table: early_larval(0 unset fields: [ ]) same_locals_1_stack_item_frame(@31,Object[#22]) same_locals_1_stack_item_frame(@50,Object[#35]) append_frame(@63,Object[#40])
It seems that two frames do not successfully merge, meaning that the early_larval frame does not have the correct set of unset fields.
The stackmap table generated in the patched class looks like this:
Attr(#34) { // StackMapTable
[] { //
246b, []{}, { // early_larval_frame
95b, []z{O,#22}; // same_locals_1_stack_item_frame
};
82b, []z{O,#35}; // same_locals_1_stack_item_frame
252b, 12, []z{O,#40}; // append_frame 1
}
}
A correct table would look like this:
Attr(#30) { // StackMapTable
[] { //
246b, []{#16; #27}, { // early_larval_frame
95b, []z{O,#29}; // same_locals_1_stack_item_frame
};
246b, []{#16; #27}, { // early_larval_frame
82b, []z{O,#32}; // same_locals_1_stack_item_frame
};
246b, []{}, { // early_larval_frame
12b; // same_frame
};
}
}
The stackmap table attribute seems to not be regenerated properly during patching
TEST RESULT: Failed. Execution failed: `main' threw exception: java.lang.VerifyError: Stack map does not match the one at exception handler 31 Exception Details: Location: TryCatchChild2.<init>()V @31: astore_1 Reason: Current frame's strict instance fields not compatible with stackmap. Current Frame: bci: @0 flags: { flagThisUninit } locals: { uninitializedThis } stack: { 'java/lang/ArrayIndexOutOfBoundsException' } Stackmap Frame: bci: @31 flags: { flagThisUninit } locals: { uninitializedThis } stack: { 'java/lang/ArrayIndexOutOfBoundsException' } Bytecode: 0000000: 2a03 b500 0104 bc0a 4cb2 0007 2b05 2eb6 0000010: 000d 2a2a 045a b500 13b5 0001 a700 234c 0000020: 2a03 b500 132a 2a04 5ab5 0013 b500 01a7 0000030: 0010 4d2a 2a04 5ab5 0013 b500 012c bf2a 0000040: b700 18b1 Exception Handler Table: bci [0, 18] => handler: 31 bci [0, 18] => handler: 50 bci [31, 37] => handler: 50 Stackmap Table: early_larval(0 unset fields: [ ]) same_locals_1_stack_item_frame(@31,Object[#22]) same_locals_1_stack_item_frame(@50,Object[#35]) append_frame(@63,Object[#40])
It seems that two frames do not successfully merge, meaning that the early_larval frame does not have the correct set of unset fields.
The stackmap table generated in the patched class looks like this:
Attr(#34) { // StackMapTable
[] { //
246b, []{}, { // early_larval_frame
95b, []z{O,#22}; // same_locals_1_stack_item_frame
};
82b, []z{O,#35}; // same_locals_1_stack_item_frame
252b, 12, []z{O,#40}; // append_frame 1
}
}
A correct table would look like this:
Attr(#30) { // StackMapTable
[] { //
246b, []{#16; #27}, { // early_larval_frame
95b, []z{O,#29}; // same_locals_1_stack_item_frame
};
246b, []{#16; #27}, { // early_larval_frame
82b, []z{O,#32}; // same_locals_1_stack_item_frame
};
246b, []{}, { // early_larval_frame
12b; // same_frame
};
}
}
The stackmap table attribute seems to not be regenerated properly during patching