0.5.0.1<div><br></div><div><div class="gmail_quote">On Tue, Jun 2, 2009 at 1:56 PM, John Van Enk <span dir="ltr"><<a href="mailto:vanenkj@gmail.com">vanenkj@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Just so we know that it's not the issue, what version of binary are<br>
you using? The most current one is 0.5.0.1.<br>
<div><div></div><div class="h5"><br>
On Tue, Jun 2, 2009 at 4:46 PM, David Leimbach <<a href="mailto:leimy2k@gmail.com">leimy2k@gmail.com</a>> wrote:<br>
><br>
><br>
> On Tue, Jun 2, 2009 at 1:36 PM, John Van Enk <<a href="mailto:vanenkj@gmail.com">vanenkj@gmail.com</a>> wrote:<br>
>><br>
>> What happens if you use `getRemainingLazyByteString' in your error<br>
>> branch instead of `getLazyByteString'?<br>
><br>
> I actually am using getRemainingLazyByteString right now, and it still<br>
> thinks I'm asking for a 20th byte.<br>
> if I delete the other guarded branch of that function, it still fails saying<br>
> I'm asking for the 20th byte.<br>
> Dave<br>
><br>
>><br>
>> On Tue, Jun 2, 2009 at 4:31 PM, David Leimbach <<a href="mailto:leimy2k@gmail.com">leimy2k@gmail.com</a>> wrote:<br>
>> ><br>
>> ><br>
>> > On Tue, Jun 2, 2009 at 1:28 PM, John Van Enk <<a href="mailto:vanenkj@gmail.com">vanenkj@gmail.com</a>> wrote:<br>
>> >><br>
>> >> I think Thomas' point was that some other branch in `getSpecific' is<br>
>> >> running. Is there a chance we can see the rest of `getSpecific'?<br>
>> ><br>
>> > Sure: (In the meantime, I'll try the suggested code from before)<br>
>> > get = do s <- getWord32le<br>
>> > mtype <- getWord8<br>
>> > getSpecific s mtype<br>
>> > where<br>
>> > getSpecific s mt<br>
>> > | mt == mtRversion = do t <- getWord16le<br>
>> > ms <- getWord32le<br>
>> > ss <- getWord16le<br>
>> > v <-<br>
>> > getRemainingLazyByteString<br>
>> > return $ MessageClient $<br>
>> > Rversion {size=s,<br>
>> ><br>
>> > mtype=mt,<br>
>> ><br>
>> > tag=t,<br>
>> ><br>
>> > msize=ms,<br>
>> ><br>
>> > ssize=ss,<br>
>> ><br>
>> > version=v}<br>
>> > | mt == mtRerror = do t <- getWord16le<br>
>> > ss <- getWord16le<br>
>> > e <- getLazyByteString $<br>
>> > fromIntegral ss<br>
>> > return $ MessageClient $<br>
>> > Rerror<br>
>> > {size=s,<br>
>> ><br>
>> > mtype=mt,<br>
>> ><br>
>> > tag=t,<br>
>> ><br>
>> > ssize=ss,<br>
>> ><br>
>> > ename=e}<br>
>> ><br>
>> >><br>
>> >> On Tue, Jun 2, 2009 at 4:20 PM, David Leimbach <<a href="mailto:leimy2k@gmail.com">leimy2k@gmail.com</a>><br>
>> >> wrote:<br>
>> >> > The thing is I have 19 bytes in the hex string I provided:<br>
>> >> > 1300000065ffff000400000600395032303030<br>
>> >> > That's 38 characters or 19 bytes.<br>
>> >> > The last 4 are 9P2000<br>
>> >> > 13000000 = 4 bytes for 32bit message payload, This is little endian<br>
>> >> > for 19<br>
>> >> > bytes total.<br>
>> >> > 65 = 1 byte for message type. 65 is "Rversion" or the response type<br>
>> >> > for<br>
>> >> > a<br>
>> >> > Tversion request<br>
>> >> > ffff = 2 bytes for 16bit message "tag".<br>
>> >> ><br>
>> >> > 00040000 = 4 bytes for the 32 bit maximum message payload size I'm<br>
>> >> > negotiating with the 9P server. This is little endian for 1024<br>
>> >> > 0600 = 2 bytes for 16 bit value for the length of the "string" I'm<br>
>> >> > sending.<br>
>> >> > The strings are *NOT* null terminated in 9p, and this is little<br>
>> >> > endian<br>
>> >> > for<br>
>> >> > 6 bytes remaining.<br>
>> >> > 5032303030 = 6 bytes the ASCII or UTF-8 string "9P2000" which is 6<br>
>> >> > bytes<br>
>> >> > 4 + 1 + 2 + 4 + 2 + 6 = 19 bytes.<br>
>> >> > As far as I can see, my "get" code does NOT ask for a 20th byte, so<br>
>> >> > why<br>
>> >> > am I<br>
>> >> > getting that error?<br>
>> >> > get = do s <- getWord32le -- 4<br>
>> >> > mtype <- getWord8 -- 1<br>
>> >> > getSpecific s mtype<br>
>> >> > where<br>
>> >> > getSpecific s mt<br>
>> >> > | mt == mtRversion = do t <- getWord16le -- 2<br>
>> >> > ms <- getWord32le -- 4<br>
>> >> > ss <- getWord16le -- 2<br>
>> >> > v <-<br>
>> >> > getRemainingLazyByteString -- remaining should be 6 bytes.<br>
>> >> > return $ MessageClient<br>
>> >> > $<br>
>> >> > Rversion {size=s,<br>
>> >> ><br>
>> >> > mtype=mt,<br>
>> >> ><br>
>> >> > tag=t,<br>
>> >> ><br>
>> >> > msize=ms,<br>
>> >> ><br>
>> >> > ssize=ss,<br>
>> >> ><br>
>> >> > version=v}<br>
>> >> > Should I file a bug? I don't believe I should be seeing an error<br>
>> >> > message<br>
>> >> > claiming a failure at the 20th byte when I've never asked for one.<br>
>> >> > Dave<br>
>> >> ><br>
>> >> > On Tue, Jun 2, 2009 at 10:51 AM, John Van Enk <<a href="mailto:vanenkj@gmail.com">vanenkj@gmail.com</a>><br>
>> >> > wrote:<br>
>> >> >><br>
>> >> >> Thomas,<br>
>> >> >><br>
>> >> >> You're correct. For some reason, I based my advice on the thought<br>
>> >> >> that<br>
>> >> >> 19 was the minimum size instead of 13.<br>
>> >> >><br>
>> >> >> On Tue, Jun 2, 2009 at 1:24 PM, Thomas DuBuisson<br>
>> >> >> <<a href="mailto:thomas.dubuisson@gmail.com">thomas.dubuisson@gmail.com</a>> wrote:<br>
>> >> >> >> I think getRemainingLazyByteString expects at least one byte<br>
>> >> >> > No, it works with an empty bytestring. Or, my tests do with<br>
>> >> >> > binary<br>
>> >> >> > 0.5.0.1.<br>
>> >> >> ><br>
>> >> >> > The specific error means you are requiring more data than<br>
>> >> >> > providing.<br>
>> >> >> > First check the length of the bytestring you pass in to the to<br>
>> >> >> > level<br>
>> >> >> > decode (or 'get') routine and walk though that to figure out how<br>
>> >> >> > much<br>
>> >> >> > it should be consuming. I notice you have a guard on the<br>
>> >> >> > 'getSpecific' function, hopefully you're sure the case you gave us<br>
>> >> >> > is<br>
>> >> >> > the branch being taken.<br>
>> >> >> ><br>
>> >> >> > I think the issue isn't with the code provided. I cleaned up the<br>
>> >> >> > code<br>
>> >> >> > (which did change behavior due to the guard and data declarations<br>
>> >> >> > that<br>
>> >> >> > weren't in the mailling) and it works fine all the way down to the<br>
>> >> >> > expected minimum of 13 bytes.<br>
>> >> >> ><br>
>> >> >> ><br>
>> >> >> >> import Data.ByteString.Lazy<br>
>> >> >> >> import Data.Binary<br>
>> >> >> >> import Data.Binary.Get<br>
>> >> >> >><br>
>> >> >> >> data RV =<br>
>> >> >> >> Rversion { size :: Word32,<br>
>> >> >> >> mtype :: Word8,<br>
>> >> >> >> tag :: Word16,<br>
>> >> >> >> msize :: Word32,<br>
>> >> >> >> ssize :: Word16,<br>
>> >> >> >> version :: ByteString}<br>
>> >> >> >> deriving (Eq, Ord, Show)<br>
>> >> >> ><br>
>> >> >> >> instance Binary RV where<br>
>> >> >> >> get = do s <- getWord32le<br>
>> >> >> >> mtype <- getWord8<br>
>> >> >> >> getSpecific s mtype<br>
>> >> >> >> where<br>
>> >> >> >> getSpecific s mt = do t <- getWord16le<br>
>> >> >> >> ms <- getWord32le<br>
>> >> >> >> ss <- getWord16le<br>
>> >> >> >> v <- getRemainingLazyByteString<br>
>> >> >> >> return $ Rversion {size=s,<br>
>> >> >> >> mtype=mt,<br>
>> >> >> >> tag=t,<br>
>> >> >> >> msize=ms,<br>
>> >> >> >> ssize=ss,<br>
>> >> >> >> version=v }<br>
>> >> >> >> put _ = undefined<br>
>> >> >> ><br>
>> >> >><br>
>> >> >><br>
>> >> >><br>
>> >> >> --<br>
>> >> >> /jve<br>
>> >> ><br>
>> >> ><br>
>> >> > _______________________________________________<br>
>> >> > Haskell-Cafe mailing list<br>
>> >> > <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
>> >> > <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
>> >> ><br>
>> >> ><br>
>> >><br>
>> >><br>
>> >><br>
>> >> --<br>
>> >> /jve<br>
>> ><br>
>> ><br>
>><br>
>><br>
>><br>
>> --<br>
>> /jve<br>
><br>
><br>
<br>
<br>
<br>
</div></div>--<br>
<font color="#888888">/jve<br>
</font></blockquote></div><br></div>