Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

Codecs that don't align at byte boundaries are unsupported? #118

Open
larsrh opened this issue Nov 21, 2016 · 0 comments
Open

Codecs that don't align at byte boundaries are unsupported? #118

larsrh opened this issue Nov 21, 2016 · 0 comments

Comments

@larsrh
Copy link

larsrh commented Nov 21, 2016

If I define a codec that doesn't align at byte boundaries, remotely doesn't like it. Here's a small reproducer: https://gist.github.com/larsrh/2d2480b3870c1165e9104225e14b94bc

According to @mpilquist this is in fact a valid codec. If I change bool to bool(8), it is aligned at byte boundaries and works as expected.

Quick digging into the sources revealed the following lines in remotely:

package object codecs extends lowerprioritycodecs {
  // [...]
  implicit val bool = C.bool(8) // use a full byte

This line has been there for at least two years, but I couldn't find any explanation anywhere. Could remotely not pad, or at least throw an exception explaining that the codec needs to be byte-aligned?

Finally, here's the stack trace:

$ sbt run
[info] Compiling 2 Scala sources to /home/lars/tmp/remotely-bug/target/scala-2.11/classes...
[info] Running Main 
[server] NEGOTIATION - got ssl parameters: None with localhost/127.0.0.1:8083
[server] NEGOTIATION - about to bind with localhost/127.0.0.1:8083
[server] NEGOTIATION - bound with localhost/127.0.0.1:8083
[server] NEGOTIATION - channel connected with /127.0.0.1:38980
[server] NEGOTIATION - sending capabilities with /127.0.0.1:38980
[server] NEGOTIATION - sent capabilities with /127.0.0.1:38980
[server] NEGOTIATION - creating queue with /127.0.0.1:38980
[server] NEGOTIATION - closing queue with /127.0.0.1:38980
[server] ----------------
[server] header: Map()
[server] trace: ac746630-5636-4905-9f07-f9d88a1d2b7a
[server] request: id(5)
[server] result: \/-(Elem((tag,List((type,int))),List(Elem((text,List((content,5))),List()))))
[server] duration: 20253373 nanoseconds
[client] ----------------
[client] header: Map()
[client] trace: ac746630-5636-4905-9f07-f9d88a1d2b7a
[client] request: id(5)
[client] result: -\/(java.lang.IllegalArgumentException: 6 bits remaining: 0x00)
[client] duration: 231969252 nanoseconds
[error] (run-main-3) java.lang.IllegalArgumentException: 6 bits remaining: 0x00
java.lang.IllegalArgumentException: 6 bits remaining: 0x00
        at scodec.interop.scalaz.package$AttemptSyntax$$anonfun$toTask$extension0$1.apply(package.scala:27)
        at scodec.interop.scalaz.package$AttemptSyntax$$anonfun$toTask$extension0$1.apply(package.scala:27)
        at scodec.interop.scalaz.package$AttemptSyntax$$anonfun$toTask$extension1$1.apply(package.scala:31)
        at scodec.interop.scalaz.package$AttemptSyntax$$anonfun$toTask$extension1$1.apply(package.scala:31)
        at scodec.Attempt$Failure.fold(Attempt.scala:113)
        at scodec.interop.scalaz.package$AttemptSyntax$.toTask$extension1(package.scala:31)
        at scodec.interop.scalaz.package$AttemptSyntax$.toTask$extension0(package.scala:27)
        at remotely.package$$anonfun$evaluate$1$$anonfun$apply$3$$anonfun$apply$4$$anonfun$apply$5$$anonfun$apply$6.apply(package.scala:76)
        at remotely.package$$anonfun$evaluate$1$$anonfun$apply$3$$anonfun$apply$4$$anonfun$apply$5$$anonfun$apply$6.apply(package.scala:70)
        at scalaz.concurrent.Task$$anonfun$flatMap$1$$anonfun$1.apply(Task.scala:36)
        at scalaz.concurrent.Task$$anonfun$flatMap$1$$anonfun$1.apply(Task.scala:36)
        at scalaz.concurrent.Task$.Try(Task.scala:389)
        at scalaz.concurrent.Task$$anonfun$flatMap$1.apply(Task.scala:36)
        at scalaz.concurrent.Task$$anonfun$flatMap$1.apply(Task.scala:34)
        at scala.Function1$$anonfun$andThen$1.apply(Function1.scala:52)
        at scalaz.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:58)
        at scalaz.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:58)
        at scalaz.concurrent.Future.step(Future.scala:109)
        at scalaz.concurrent.Future.listen(Future.scala:75)
        at scalaz.concurrent.Future$$anonfun$listen$1$$anonfun$apply$4.apply(Future.scala:79)
        at scalaz.concurrent.Future$$anonfun$listen$1$$anonfun$apply$4.apply(Future.scala:79)
        at scalaz.Free$$anonfun$map$1.apply(Free.scala:52)
        at scalaz.Free$$anonfun$map$1.apply(Free.scala:52)
        at scalaz.Free.scalaz$Free$$fastFlatMap(Free.scala:71)
        at scalaz.Free$$anonfun$resume$1.apply(Free.scala:87)
        at scalaz.Free$$anonfun$resume$1.apply(Free.scala:87)
        at scalaz.std.FunctionInstances$$anon$1$$anonfun$map$1.apply(Function.scala:56)
        at scalaz.Free$$anonfun$run$1.apply(Free.scala:186)
        at scalaz.Free$$anonfun$run$1.apply(Free.scala:186)
        at scalaz.Free.go2$1(Free.scala:133)
        at scalaz.Free.go(Free.scala:136)
        at scalaz.Free.run(Free.scala:186)
        at scalaz.concurrent.Future$$anonfun$async$1$$anonfun$apply$14.apply(Future.scala:376)
        at scalaz.concurrent.Future$$anonfun$async$1$$anonfun$apply$14.apply(Future.scala:376)
        at scalaz.stream.async.mutable.Queue$$anonfun$1.apply(Queue.scala:222)
        at scalaz.stream.async.mutable.Queue$$anonfun$1.apply(Queue.scala:221)
        at scalaz.stream.async.mutable.Queue$$anonfun$scalaz$stream$async$mutable$Queue$$stop$1$4$$anonfun$apply$8.apply$mcV$sp(Queue.scala:282)
        at scalaz.stream.async.mutable.Queue$$anonfun$scalaz$stream$async$mutable$Queue$$stop$1$4$$anonfun$apply$8.apply(Queue.scala:282)
        at scalaz.stream.async.mutable.Queue$$anonfun$scalaz$stream$async$mutable$Queue$$stop$1$4$$anonfun$apply$8.apply(Queue.scala:282)
        at scalaz.concurrent.StrategysLow$$anon$3$$anon$4.call(Strategy.scala:79)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
[trace] Stack trace suppressed: run last compile:run for the full output.
java.lang.RuntimeException: Nonzero exit code: 1
        at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) Nonzero exit code: 1
[error] Total time: 2 s, completed 21.11.2016 22:11:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant