Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: java.lang.VerifyError catching exception with unapply in nested finally blocks #8925

Closed
scabug opened this issue Oct 17, 2014 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Oct 17, 2014

In nested finally blocks, a VerifyError occurs when attempting to pattern match on a caught exception.

Minimal test case:
{code}object Test {
def unapply(t: Throwable): Option[Throwable] = Some(t)
}

object Main{
def main(args: Array[String]) {
try {
()
} finally {
try {
()
} finally {
try {
throw null
} catch {
case Test(_) =>
}
}
}
}
}{code}

Expected output is empty. With -Xoldpatmat, no errors occur.

Without -Xoldpatmat, on both 2.10.3 and 2.11.2, the error is as follows:

Exception in thread "main" java.lang.VerifyError: Bad local variable type
Exception Details:
  Location:
    Main$.main([Ljava/lang/String;)V @144: aload
  Reason:
    Type top (current frame, locals[8]) is not assignable to reference type
  Current Frame:
    bci: @144
    flags: { }
    locals: { 'Main$', '[Ljava/lang/String;', top, top, 'java/lang/Throwable', 'java/lang/Throwable', 'scala/Option', 'scala/runtime/BoxedUnit' }
    stack: { }
  Bytecode:
    0000000: 01bf bf00 bfbf 00bf 00bf 0000 00bf 0000
    0000010: 0000 0000 0000 00bf 0000 0000 0000 00bf
    0000020: 0000 bf00 0000 00bf 00bf 00bf 0000 00bf
    0000030: 0000 0000 0000 0000 00bf 0000 0000 0000
    0000040: 00bf 0000 bf00 0000 00bf 00bf 00bf 00bf
    0000050: 00bf 0000 00bf 0000 0000 0000 0000 00bf
    0000060: 0000 0000 0000 00bf 0000 0000 bf00 00bf
    0000070: 3a04 1904 3a05 b200 1319 05b6 0017 3a06
    0000080: 1906 b600 1d99 0006 1904 bfb2 0023 3a07
    0000090: 1908 bf                                
  Exception Handler Table:
    bci [0, 2] => handler: 112
  Stackmap Table:
    full_frame(@2,{},{Object[#40]})
    same_locals_1_stack_item_frame(@3,Object[#40])
    same_locals_1_stack_item_frame(@5,Object[#40])
    same_locals_1_stack_item_frame(@6,Object[#40])
    same_locals_1_stack_item_frame(@8,Object[#40])
    same_locals_1_stack_item_frame(@10,Object[#40])
    same_locals_1_stack_item_frame(@14,Object[#40])
    same_locals_1_stack_item_frame(@24,Object[#40])
    same_locals_1_stack_item_frame(@32,Object[#40])
    same_locals_1_stack_item_frame(@35,Object[#40])
    same_locals_1_stack_item_frame(@40,Object[#40])
    same_locals_1_stack_item_frame(@42,Object[#40])
    same_locals_1_stack_item_frame(@44,Object[#40])
    same_locals_1_stack_item_frame(@48,Object[#40])
    same_locals_1_stack_item_frame(@58,Object[#40])
    same_locals_1_stack_item_frame(@66,Object[#40])
    same_locals_1_stack_item_frame(@69,Object[#40])
    same_locals_1_stack_item_frame(@74,Object[#40])
    same_locals_1_stack_item_frame(@76,Object[#40])
    same_locals_1_stack_item_frame(@78,Object[#40])
    same_locals_1_stack_item_frame(@80,Object[#40])
    same_locals_1_stack_item_frame(@82,Object[#40])
    same_locals_1_stack_item_frame(@86,Object[#40])
    same_locals_1_stack_item_frame(@96,Object[#40])
    same_locals_1_stack_item_frame(@104,Object[#40])
    same_locals_1_stack_item_frame(@109,Object[#40])
    full_frame(@112,{Object[#2],Object[#41]},{Object[#40]})
    full_frame(@136,{Object[#2],Object[#41],Top,Top,Object[#40],Object[#40],Object[#25]},{})
    same_frame(@139)
    append_frame(@144,Object[#31])

	at Main.main(test.scala)

Note also that is one level of try/finally is removed the issue does not occur.

@scabug
Copy link
Author

scabug commented Oct 17, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8925?orig=1
Reporter: William Owen Parry (oparry)
Affected Versions: 2.10.3, 2.11.2
See #7407

@scabug
Copy link
Author

scabug commented Oct 17, 2014

@retronym said:
Possible the same underlying issue as #7407

@scabug
Copy link
Author

scabug commented Oct 20, 2014

@lrytz said:
Works in new backend, scala/scala#4068, so will be fixed in 2.12

@scabug
Copy link
Author

scabug commented Nov 18, 2014

@retronym said:
Fixed in 2.11.5 under -Ybackend:GenBCode, which will be non-experimental and enabled by default in the 2.12 series soon.

@scabug scabug closed this as completed Nov 18, 2014
@scabug scabug added this to the 2.12.0-M1 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants