You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into this problem and have reduced it down to the following repro.
It seems to be that the SequenceSegment Blocks cache for pooling on dispose of the first serialization session manages to get the same segment added twice and since it's a ConcurrentBag the set is not distinct.
This means that the second serialization attempt gets the pooled blocks and the first two requests get the same SequenceSegment which causes an odd linked list and data to be lost
usingMicrosoft.Extensions.DependencyInjection;usingOrleans.Serialization;usingOrleans.Serialization.Buffers;usingOrleans.Serialization.Buffers.Adaptors;usingOrleans.Serialization.Session;namespaceOrleansSerializerBug;internalclassProgram{staticvoidMain(string[]args){varserviceProvider=newServiceCollection().AddSerializer().BuildServiceProvider();varpool=serviceProvider.GetRequiredService<SerializerSessionPool>();varserializer=serviceProvider.GetRequiredService<Serializer>();varobj=LargeObject.BuildRandom();// First Works FineSerializeObject(pool,serializer,obj);// Second FailsSerializeObject(pool,serializer,obj);staticvoidSerializeObject(SerializerSessionPoolpool,Serializerserializer,LargeObjectobj){Writer<PooledArrayBufferWriter>writer=default;try{writer=Writer.CreatePooled(pool.GetSession());serializer.Serialize(obj,refwriter);varsequence=writer.Output.AsReadOnlySequence();if(sequence.Length!=writer.Output.Length){Console.WriteLine($""" Output sequence has length "{sequence.Length}" that does not match writer output length "{writer.Output.Length}"""");}}finally{writer.Dispose();}}}}[GenerateSerializer]publicreadonlyrecordstructLargeObject([property:Id(0)]GuidId,[property:Id(1)](Guid,Guid)[]Values){publicstaticLargeObjectBuildRandom(){varid=Guid.NewGuid();varvalues=new(Guid,Guid)[256];for(vari=0;i<values.Length;i++){values[i]=(Guid.NewGuid(),Guid.NewGuid());}returnnew(id,values);}}
The text was updated successfully, but these errors were encountered:
I ran into this problem and have reduced it down to the following repro.
It seems to be that the
SequenceSegment
Blocks cache for pooling on dispose of the first serialization session manages to get the same segment added twice and since it's a ConcurrentBag the set is not distinct.This means that the second serialization attempt gets the pooled blocks and the first two requests get the same
SequenceSegment
which causes an odd linked list and data to be lostThe text was updated successfully, but these errors were encountered: