[CSHARP-1261] Using _ts as element name for types participating in a class hierarchy leads to crash Created: 29/Apr/15  Updated: 29/Apr/15  Resolved: 29/Apr/15

Status: Closed
Project: C# Driver
Component/s: BSON
Affects Version/s: 2.0
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Ioan Crisan Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: driver
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Zip Archive MongoDBTests.zip    
Issue Links:
Duplicate
duplicates CSHARP-1255 An ignored BsonElement with a prefix ... Closed

 Description   

I have the following entities:

[BsonDiscriminator(RootClass = true)]
[BsonKnownTypes(typeof(SysAdminRole))]
public class Role : DocumentEntityBase
{
[BsonElement("_ts")]
public BsonTimestamp Timestamp

{ get; set; }

[BsonRequired]
public string Name { get; set; }

}

public class SysAdminRole : Role
{
}

To reproduce the error see the Add_and_read_roles test in the attached project. Note that changing the element name to s_ts does not generate exceptions anymore, as well as using other letters after _, like _c. It may be related to the fact that the element name holding the type information is named _t.

Inserting entities of these types is ok, but when trying to read them, I get the following exception:

System.IO.EndOfStreamException: Attempted to read past the end of the stream.
at MongoDB.Bson.IO.BsonStreamExtensions.ReadBsonType(BsonStream stream)
at MongoDB.Bson.IO.BsonBinaryReader.ReadBsonType()
at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.DeserializeClass(BsonDeserializationContext context)
at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
at MongoDB.Bson.Serialization.Serializers.SerializerBase`1.MongoDB.Bson.Serialization.IBsonSerializer.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize(IBsonSerializer serializer, BsonDeserializationContext context)
at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize(IBsonSerializer`1 serializer, BsonDeserializationContext context)
at MongoDB.Driver.Core.WireProtocol.Messages.Encoders.BinaryEncoders.ReplyMessageBinaryEncoder`1.ReadMessage()
at MongoDB.Driver.Core.WireProtocol.Messages.Encoders.BinaryEncoders.ReplyMessageBinaryEncoder`1.MongoDB.Driver.Core.WireProtocol.Messages.Encoders.IMessageEncoder.ReadMessage()
at MongoDB.Driver.Core.Connections.BinaryConnection.<ReceiveMessageAsync>d__15.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at MongoDB.Driver.Core.WireProtocol.QueryWireProtocol`1.<ExecuteAsync>d__0.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at MongoDB.Driver.Core.Servers.ClusterableServer.ServerChannel.<ExecuteProtocolAsync>d__25`1.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at MongoDB.Driver.Core.Operations.FindOperation`1.<ExecuteAsync>d__2.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at MongoDB.Driver.OperationExecutor.<ExecuteReadOperationAsync>d__0`1.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at MongoDB.Driver.MongoCollectionImpl`1.<ExecuteReadOperation>d__35`1.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at MongoDBTests.HierarchyTest.<Add_and_read_roles>d__5.MoveNext() in HierarchyTest.cs: line 27
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()



 Comments   
Comment by Craig Wilson [ 29/Apr/15 ]

Hi loan,

This is the same as CSHARP-1255, which is already fixed. We'll be putting out a 2.0.1 because of this bug shortly.

Craig

Generated at Wed Feb 07 21:39:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.