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

list inside union: java.lang.VerifyError and "Error exists in the bytecode" #118

Closed
fleminra opened this issue Apr 9, 2014 · 16 comments
Closed

Comments

@fleminra
Copy link

fleminra commented Apr 9, 2014

The following compiles fine but has a runtime error when f() is invoked:

union Value
{
  // fails
  1: list<i32> b;
}

service Service
{
  Value f();
}

The mere presence of a list inside the union causes this problem, even if the server code does not create a union that uses the field defined as the list.

The error:

SEVERE: A server service  threw an exception
java.lang.VerifyError: Uninitialized object exists on backward branch 133
Exception Details:
  Location:
    thrift/Value$.decode(Lorg/apache/thrift/protocol/TProtocol;)Lthrift/Value; @162: goto
  Reason:
    Error exists in the bytecode
  Bytecode:
    0000000: 0157 014d 2bb6 0030 572b b600 334e 2db4
    0000010: 0039 3604 1504 aa00 0000 0012 0000 0001
...
  Stackmap Table:
    append_frame(@40,Null,Object[#53],Integer)
    same_frame(@51)
    append_frame(@76,Integer)
    same_frame(@87)
    full_frame(@116,{Object[#2],Object[#45],Null,Object[#53],Integer,Integer,Object[#75]},{Uninitialized[#87],Uninitialized[#87]})
    full_frame(@133,{Object[#2],Object[#45],Null,Object[#53],Integer,Integer,Object[#75],Object[#89],Integer},{Uninitialized[#87],Uninitialized[#87]})
    full_frame(@165,{Object[#2],Object[#45],Null,Object[#53],Integer,Integer,Object[#75],Object[#89],Integer},{Uninitialized[#87],Uninitialized[#87]})
    full_frame(@171,{Object[#2],Object[#45],Null,Object[#53],Integer,Integer,Object[#75]},{Uninitialized[#87],Uninitialized[#87],Object[#137]})
    full_frame(@175,{Object[#2],Object[#45],Object[#69],Object[#53],Integer},{})
    full_frame(@193,{Object[#2],Object[#45],Object[#69],Object[#53],Integer,Top,Top,Top,Top,Integer,Integer},{})
    same_frame(@217)
    append_frame(@238,Object[#53])
    full_frame(@257,{Object[#2],Object[#45],Object[#69],Object[#53],Integer},{})
    same_frame(@275)

    at thrift.Value$B.write(Value.scala:87)
    at thrift.Service$f$result$class.write(Service.scala:219)
    at thrift.Service$f$result$Immutable.write(Service.scala:194)
    at thrift.Service$FinagledService.reply(Service.scala:366)
    at thrift.Service$FinagledService$$anonfun$1$$anonfun$apply$7.apply(Service.scala:402)
    at thrift.Service$FinagledService$$anonfun$1$$anonfun$apply$7.apply(Service.scala:401)
    at com.twitter.util.Future$$anonfun$flatMap$1.apply(Future.scala:781)
    at com.twitter.util.Future$$anonfun$flatMap$1.apply(Future.scala:780)
    at com.twitter.util.ConstFuture$$anonfun$transform$1.apply(Future.scala:1074)
    at com.twitter.util.ConstFuture$$anonfun$transform$1.apply(Future.scala:1073)
    at com.twitter.util.ConstFuture$$anon$4$$anonfun$run$1.apply$mcV$sp(Future.scala:1063)
    at com.twitter.util.Monitor$.apply(Monitor.scala:128)
    at com.twitter.util.ConstFuture$$anon$4.run(Future.scala:1063)
    at com.twitter.concurrent.LocalScheduler$Activation.run(Scheduler.scala:129)
    at com.twitter.concurrent.LocalScheduler$Activation.submit(Scheduler.scala:107)
    at com.twitter.concurrent.LocalScheduler.submit(Scheduler.scala:150)
    at com.twitter.concurrent.Scheduler$.submit(Scheduler.scala:59)
    at com.twitter.util.Promise.runq(Promise.scala:310)
    at com.twitter.util.Promise.updateIfEmpty(Promise.scala:605)
    at com.twitter.util.Promise.update(Promise.scala:583)
    at com.twitter.util.Promise.setValue(Promise.scala:559)
    at com.twitter.concurrent.AsyncQueue.offer(AsyncQueue.scala:71)
    at com.twitter.finagle.transport.ChannelTransport.handleUpstream(ChannelTransport.scala:41)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboy.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.channel.SimpleChannelHandler.messageReceived(SimpleChannelHandler.java:142)
    at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:88)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
    at org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java:70)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
    at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462)
    at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:443)
    at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
    at com.twitter.finagle.thrift.ThriftFrameCodec.handleUpstream(ThriftFrameCodec.scala:17)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
    at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
    at org.jboss.netty.channel.socket.nio.AbstractNioSerun(AbstractNioSelector.java:318)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
    at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
    at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
    at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)

Versions:

  • com.twitter:finagle-thrift_2.10:6.13.1
  • com.twitter:scrooge-runtime_2.10:3.13.0
  • org.apache.thrift:libthrift:0.9.1
  • org.scala-lang:scala-library:2.10.4
  • Oracle Java 1.7.0_51

Here's Server.scala:

object Server
{
  def main(args: Array[String])
  {
    import thrift.{Value, Service}

    class ServiceImpl extends Service.FutureIface
    {
      import com.twitter.util.Future

      def f(): Future[Value] = Future(Value.B(Array(4)))
    }

    val service = new Service.FinagledService(new ServiceImpl,
                          new org.apache.thrift.protocol.TBinaryProtocol.Factory)

    val server = com.twitter.finagle.builder.ServerBuilder()
      .bindTo(new java.net.InetSocketAddress(2000))
      .codec(com.twitter.finagle.thrift.ThriftServerFramedCodec())
      .name("thriftserver")
      .build(service)
  }
}

I'm invoking it from CPython + Thrift 0.9.1.

Am I doing anything wrong? I'm somewhat new to Thrift.

Thanks!

@sprsquish
Copy link
Contributor

I'll write up a test case and see if I can reproduce and fix this.

@sprsquish
Copy link
Contributor

What version of the generator are you using?

@fleminra
Copy link
Author

I'm using scrooge-gradle-plugin 0.5, which in turn brings in scrooge-generator 3.9.1, which I see only now is out of date. Does this not occur with newer versions of scrooge-generator? Thanks.

@sprsquish
Copy link
Contributor

I can't reproduce it with the latest code.

@fleminra
Copy link
Author

I've updated my build script to use scrooge-generator 3.13.1 but am still seeing the issue. I've pushed the example code to https://github.com/fleminra/thrift-list-in-union-demo and am able to reproduce the problem on a few different server computers (Linux and Windows). You can use ./gradlew run in the server directory to download all the dependencies (including Gradle), compile, and run.

I suppose there must be some dependency version mismatch between what you're doing and I'm doing. I notice that:

  • scrooge-generator_2.10:3.13.1 depends on org.apache.thrift:libthrift:0.8.0
  • com.twitter:finagle-thrift_2.10:6.13.1 depends on org.apache.thrift:libthrift:0.5.0
  • my server depends on org.apache.thrift:libthrift:0.9.1

Not sure if that's a problem. I tried rolling my own dependency back to 0.8.0, with no improvement.

@sprsquish
Copy link
Contributor

I think the libthrift version mismatch might be a possibility too.

I can't get the example to run because I can't reach quannum.ssd.loral.com

@fleminra
Copy link
Author

Ah, sorry, it's just a caching Maven server in this instance. Fixed.

@sprsquish
Copy link
Contributor

I can no reproduce this. Looking into it.

@sprsquish
Copy link
Contributor

Tracked this down to scala 2.10. If I drop the version down to 2.9.2, everything works. Not sure why. Still looking.

@sprsquish
Copy link
Contributor

Oh wait. I moved the libraries. I don't know how to change the scala compiler that gradle uses. If gradle is using the 2.9 compiler it's not going to work with the 2.10 libraries. Any ideas on what version gradle is using?

@fleminra
Copy link
Author

Unfortunately all versions of scrooge-gradle-plugin depend on Scala 2.10.2, so I think that makes it hard to force Gradle to use Scala 2.9.

I'm currently trying to distill down the simple command-lines to replicate what Gradle is doing for (1) scrooge-generator, (2) scalac, and (3) running the server. That way I can and control see the exact versions of everything.

@fleminra
Copy link
Author

I've made two more commits to my repo:

  • fleminra/thrift-list-in-union-demo@efc39c0 switches to Gradle's "Zinc" scalac from its "Ant" scalac. With this change, the problem goes away.
  • fleminra/thrift-list-in-union-demo@00a7125 adds three shell scripts, for (1) Scrooge compiling, (2) Scala compiling, and (3) running the server. These three are derived from what I observed Gradle doing (with its Ant scalac); running these three (instead of Gradle) also somehow fixes the problem.

Gradle has a "distTar" task that creates a standalone distribution of the server, such that the server can be run via a shell script (so that it's no longer running under the Gradle process). When the server is compiled with the Gradle Ant scalac, and executed via this "distTar", the problem still occurs.

So it looks like the problem is in the Scala compilation phase.

I'm still comparing Gradle's debug output between the non-working and working build steps. Still hard to say at this point where the bug lies.

@boclair
Copy link

boclair commented Jan 14, 2015

I'm encountering the same bug, and I also have a union with a list in it.

Using scrooge 3.17, thrift 0.9.2, and sbt 13.6

Any updates?

@nshkrob
Copy link
Contributor

nshkrob commented Jan 15, 2015

The example from the first comment works for me (I've modified https://github.com/twitter/finagle/tree/master/finagle-example to run it). Note that finagle uses libthrift 0.5.0.
How are you running it and what are you seeing?

@boclair
Copy link

boclair commented Jan 15, 2015

Thanks for replying. In summary I fixed my problem by upgrading to JDK version 1.8.0_25.

I believe that scrooge was generating code that was hitting this bug https://issues.scala-lang.org/browse/SI-8645 And thus throwing a

java.lang.VerifyError: Uninitialized object exists on backward branch 240

I have more info if you are curious, but I believe the issue to be resolved now. Thanks.

@nshkrob
Copy link
Contributor

nshkrob commented Jan 15, 2015

Great, thanks for digging into this. I'm closing the issue.

@nshkrob nshkrob closed this as completed Jan 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants