Skip to content

UnCurry forgets to liftTree, causing java.lang.VerifyError down the road #6863

@scabug

Description

@scabug

I'm trying to use a modified version of https://github.com/romix/akka-kryo-serialization with Scala 2.10.0-RC5. It compiles fine (without -optimise, with the flag it crashes, but that's a different issue), but then at class load-time I get the following error:

Could not run test org.hyflow.KryoTest: java.lang.VerifyError: (class: com/romix/scala/serialization/kryo/ScalaSetSerializer, method: create signature: (Lcom/esotericsoftware/kryo/Kryo;Lcom/esotericsoftware/kryo/io/Input;Ljava/lang/Class; )Lscala/collection/Set; ) Inconsistent stack height 1 != 3

Even Soot refuses to load the class properly, and gives the following:

Considering 111: invokenonvirtual[111]
Exception in thread "main" java.lang.RuntimeException: TypeStack merging failed; unequal stack lengths: 1 and 3
	at soot.coffi.TypeStack.merge(TypeStack.java:137)
	at soot.coffi.CFG.jimplify(CFG.java:1196)
	at soot.coffi.CFG.jimplify(CFG.java:955)
	...

The code that causes the problem appears to be at the end of this block, as the three branches are collected into the final result (line labeled 111 in the 2.10 bytecode file):

var coll: Map[Any, Any] = 
if(classOf[SortedMap[_,_]].isAssignableFrom(typ)) {
// Read ordering and set it for this collection 
implicit val mapOrdering = kryo.readClassAndObject(input).asInstanceOf[scala.math.Ordering[Any]]
	try typ.getDeclaredConstructor(classOf[scala.math.Ordering[_]]).newInstance(mapOrdering).asInstanceOf[Map[Any,Any]].empty 
	catch { case _ => kryo.newInstance(typ).asInstanceOf[Map[Any,Any]].empty }
} else {
	kryo.newInstance(typ).asInstanceOf[Map[Any,Any]].empty
}

This code worked on 2.9.1, and it appears the generated bytecode is indeed different. I've attached the source code excerpt and disassembled bytecode for 2.9.1 and 2.10.0-RC5, and highlighted the line with the problem in the 2.10 bytecode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions