DerrickBrayanClayton / protobuf-net

Automatically exported from code.google.com/p/protobuf-net
0 stars 0 forks source link

Occasional exceptions caught #34

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Please include an e-mail address if this might need a dialogue!
==============
Email: paszczi@go2.pl

What steps will reproduce the problem?
1. Error occurs occasionally  when deserializing message from Stream.
StackTrace I get is:

The exception is NullReferenceException

ProtoBuf.Serializer`1.Deserialize(T& instance, SerializationContext
context) in d:\\protobuf-net\\trunk\\protobuf-net\\SerializerT.cs:line
489\r\n  in ProtoBuf.Serializer`1.Deserialize(T& instance, Stream source) w
d:\\protobuf-net\\trunk\\protobuf-net\\SerializerT.cs:line 358\r\n   w
ProtoBuf.SerializerItemProxy`1.Deserialize(TItem& instance, Stream source)
in d:\\protobuf-net\\trunk\\protobuf-net\\SerializerProxy.cs:line 64\r\n  
in ProtoBuf.Serializer.Deserialize[T](Stream source) in
d:\\protobuf-net\\trunk\\protobuf-net\\Serializer.cs:line 251\r\n   w
SecPL.Return.CoreLib.NetworkServices.NetworkUtils.DeserializeMessage[T](Stream
source)"

Original issue reported on code.google.com by maciej.p...@gmail.com on 2 Dec 2008 at 10:17

GoogleCodeExporter commented 8 years ago
Is there any specific scenario that reproduces this? I wonder (for example) 
whether 
it is something to do with list-properties where the bespoke list doesn't have 
a 
default constructor...

I can try to investigate, but very hard without a reproducable scenario.

Original comment by marc.gravell on 2 Dec 2008 at 12:11

GoogleCodeExporter commented 8 years ago
I tried to reproduce it, but it really happens occasionally.  I've attached
definitions of my objects, maybe this will help. Each message is sent in Message
object. Each message has 'bytes payload', which is another ProtoBuf serialized
message. The error occurs when deserializing payload content (always). It 
cannot be
null (if it was, earlier functions would throw appropriate exception) even if I 
tried
to pass null, byte[0] the outcome was completely different. Payload contains 
either
ObjectHubResponse or RequestMessages

Original comment by maciej.p...@gmail.com on 2 Dec 2008 at 3:05

Attachments:

GoogleCodeExporter commented 8 years ago
OK I think I've got the problem. As I've mentioned the problem happened 
occasionally.
My environment is multithreaded with Protobuf.Serializer called from different
threads possibly at the same time. I wrongly assumed that since Serializer is 
static
it's thread-safe but it's not. Now I've created utility class that serializes 
access
to Serializer. So far so good :)

Original comment by maciej.p...@gmail.com on 3 Dec 2008 at 9:07

GoogleCodeExporter commented 8 years ago
Really? That is curious! It *should* be thread-safe. It is intended to be. I 
will 
investigate, but I can't think (without looking) why this would happen... the 
only 
thing (without checking) that could break this would be the Build() method 
which 
constructs the strategy per-type, but that should still be safe!

I will *definitely* look at this on the train tomorrow!

Thanks for the update.

Original comment by marc.gravell on 3 Dec 2008 at 10:59

GoogleCodeExporter commented 8 years ago
Well, the software now runs for 2 days without this error - so maybe the
thread-safety is the issue here. 

Original comment by maciej.p...@gmail.com on 4 Dec 2008 at 9:10

GoogleCodeExporter commented 8 years ago
I'm happy to believe you - I am investigating. Thanks for reporting this.

Original comment by marc.gravell on 4 Dec 2008 at 9:29

GoogleCodeExporter commented 8 years ago

Original comment by marc.gravell on 9 Dec 2008 at 8:35

GoogleCodeExporter commented 8 years ago
Closed (verified)

Original comment by marc.gravell on 6 Jan 2009 at 7:51