On Wed, Jan 19, 2011 at 4:07 PM, Albert Strasheim <ful...@gmail.com> wrote:
> Is the gob Decoder intended to survive random input bytes?
> It seems random input causes three kinds of errors in Decode:
> - err return
> - gob-initiated panic
> - runtime panic (invalid argument to makeslice)
To be more explicit:
We can deal with the error return and recover the gob-initiated panic.
However, runtime panics aren't really something we want to recover
from: we just repanic.
This seems like the most sensible thing to do, since it's hard to
distinguish between a "minor" runtime panic (like gob messing up an
argument to make(...)) and a "major" one (like nil pointer
dereference).
Regards
Albert
I worry that people will not check its errors, but let that be on their heads.
-rob
Using gobs as part of the rpc package we have noticed that there are
often panics in the encoders/decoders during routine network flakiness
[1]. I personally much prefer to check errors instead of having to
brace every call to rpc with defer's. Specifically, in my opinion, a
package like gob or rpc should never panic due to malformed input.
Kai
[1] the one we are seeing most is when input is cut short for some reason.
--
Kai Backman, programmer
http://tinkercad.com - The unprofessional solid CAD
> On Fri, Jan 21, 2011 at 8:16 PM, Rob 'Commander' Pike <r...@golang.org> wrote:
>> I worry that people will not check its errors, but let that be on their heads.
>
> Using gobs as part of the rpc package we have noticed that there are
> often panics in the encoders/decoders during routine network flakiness
> [1]. I personally much prefer to check errors instead of having to
> brace every call to rpc with defer's. Specifically, in my opinion, a
> package like gob or rpc should never panic due to malformed input.
I think that's what I said.
-rob