Debug assertion failed while attempting to set an object

75 views
Skip to first unread message

Rajesh Khan

unread,
Aug 28, 2013, 1:31:41 PM8/28/13
to prot...@googlegroups.com

I currently have something like this. I get an error when i attempt to store data in a message that has multiple message types in it.

message MyTypeA
{
optional string Account = 1 ;
optional string Name = 2 ;
}

message MyTypeB
{
optional int32 position = 1;
}   

message MyCollection
{
optional MyTypeA= 1;
optional MyTypeB pos = 2;
}


Now I am using it as

void SomeMethod(MyTypeA& mta)
{
 MyCollection col;
 col.set_allocated_MyTypeA(&mta); //This point eventually fires of a debug assertion
}

The error I get is
Debug assertion failed.
Expression : _BLOCK_TYPE_IS_VALID(pHead->nBlockUse);


Any suggestion on where I might be going wrong


Feng Xiao

unread,
Aug 28, 2013, 7:14:49 PM8/28/13
to Rajesh Khan, Protocol Buffers
On Wed, Aug 28, 2013 at 10:31 AM, Rajesh Khan <rajesh...@gmail.com> wrote:

I currently have something like this. I get an error when i attempt to store data in a message that has multiple message types in it.

message MyTypeA
{
optional string Account = 1 ;
optional string Name = 2 ;
}

message MyTypeB
{
optional int32 position = 1;
}   

message MyCollection
{
optional MyTypeA= 1;
optional MyTypeB pos = 2;
}


Now I am using it as

void SomeMethod(MyTypeA& mta)
{
 MyCollection col;
 col.set_allocated_MyTypeA(&mta); //This point eventually fires of a debug assertion
mta must be a object allocated on heap.

}

The error I get is
Debug assertion failed.
Expression : _BLOCK_TYPE_IS_VALID(pHead->nBlockUse);


Any suggestion on where I might be going wrong


--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages