[omniORB] String handling problem with VC7.1

bjorn rohde jensen bjensen at fastmail.fm
Thu Mar 22 19:05:31 GMT 2007


Matej Kenda wrote:
> Hi Severin,
> 
> 2007/3/22, Ecker Severin <Severin.Ecker at arcs.ac.at>:
> 
>>
>> static inline void free(char* s) {
>>   if (s && s != empty_string) delete[] s;
>> }
>>
>> For some reason the condition hold true and attempts are made to delete
>> an invalid string resource. As you can see above I just want to assign a
>> string to a completely new and fresh corba object (the id string) which
>> does have the value 'empty_string' at the time of my assignment
>> statement.
> 
> 
> I suspect that you are using non-debug and debug versions of MS C
> runtime library: one is used by the omniORB and the other is used by
> your application.
> 
> The string gets allocated in one heap and wants to get deallocated in
> another.
> 
> HTH,
> 
> Matej

I would say,the problem is, when you assign the constant pointer to
var.id, var assumes ownership of the memory pointed to, and it will
attempt to free it, when the variable releases ownership of it.
CosNaming::Name behaves like _var types in that respect, and your
runtime is quite right to complain about freeing string constants.



More information about the omniORB-list mailing list