[omniORB] Problem of CORBA::String in MFC Application

Guy Trudel gtrudel@mediatrix.com
Fri, 26 Nov 1999 09:51:51 -0500


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01BF381D.C7B0EF70
Content-Type: text/plain;
	charset="gb2312"

Do you have the same problem with only
int CWSInfoApp::InitCorbaServer(CORBA::ORB_ptr orb, ... myobj )
{
   CORBA::String_var p = orb->object_to_string(myobj);
    return(0); 
}
and no other code ?
 
Maybe some hints
void FunctionA()
{
    CORBA::String_var src = "A string"; // Will cause an error since "..."
is a char*
                                                         // and
~CORBA::String_var will try to delete
                                                        // the actual char*
 
    CORBA::String_var src2 = (const char*)"A string"; // Will make a copy of
the string
}
char* FunctionB()
{
    CORBA::String_var src = (const char*)"A string"; // Will make a copy of
the string
    
    return CORBA::string_dup(src); // Will return a copy of src
}
 
Guy Trudel
 
 -----Original Message-----
From: Jeffrey Du [mailto:jeffdu@163.net]
Sent: Saturday, December 04, 1999 11:26 PM
To: omniorb-list@uk.research.att.com
Subject: [omniORB] Problem of CORBA::String in MFC Application



   I am writing a CORBA program in VC++ 5.0 using omniORB 2.8 in Windows95.
I find that
any functions in my program using CORBA::String will encounter an error when
they return.
For example, here is my code of the function:
 
int CWSInfoApp::InitCorbaServer()
{
   ...... 
   CORBA::String_var p = orb->object_to_string(myobj);
   ...... 
 
   return(0); // an error occurs after return
}
 
   And the error message is:
 
   Microsoft Visual C++ Debug Library
        Debug Assertion Failed
        Program:  .....
        File: dbgdel.cpp
        Line: 47
        Exception: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
 
   I think the error occurs when releasing CORBA::String memory. 
   Please tell me how to solve this problem.
 
   Jeffrey Du
   jeffdu@163.net <mailto:jeffdu@163.net> 


------_=_NextPart_001_01BF381D.C7B0EF70
Content-Type: text/html;
	charset="gb2312"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dgb2312">


<META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR></HEAD>
<BODY bgColor=3D#c0c0c0>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D562082814-26111999>Do =
you have the same=20
problem with only</SPAN></FONT></DIV>
<DIV><SPAN class=3D562082814-26111999>
<DIV><FONT face=3DArial size=3D2>int =
CWSInfoApp::InitCorbaServer(CORBA::ORB_ptr=20
orb<SPAN class=3D562082814-26111999>, ... myobj </SPAN>)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; CORBA::String_var p =3D=20
orb-&gt;object_to_string(myobj);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; return(0); =
</FONT></DIV>
<DIV><FONT size=3D2><FONT face=3DArial>}<SPAN=20
class=3D562082814-26111999></SPAN></FONT></FONT></DIV>
<DIV><FONT size=3D2><FONT face=3DArial><SPAN =
class=3D562082814-26111999>and no other=20
code ?</SPAN></FONT></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D562082814-26111999>Maybe =
some=20
hints</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D562082814-26111999>void=20
FunctionA()</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D562082814-26111999>{</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D562082814-26111999>&nbsp;&nbsp;&nbsp;=20
CORBA::String_var src =3D "A string"; // Will cause an error since =
"..." is a=20
char*</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D562082814-26111999>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;=20
// and ~CORBA::String_var will try to delete</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D562082814-26111999>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
// the actual char*</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D562082814-26111999></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D562082814-26111999>&nbsp;&nbsp;&nbsp;=20
CORBA::String_var src2 =3D (const char*)"A string"; // Will make a copy =
of the=20
string</SPAN></FONT><FONT face=3DArial size=3D2><SPAN=20
class=3D562082814-26111999></SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D562082814-26111999></SPAN></FONT><FONT=20
face=3DArial size=3D2><SPAN =
class=3D562082814-26111999>}</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D562082814-26111999>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D562082814-26111999>char* =

FunctionB()</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D562082814-26111999>{</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D562082814-26111999>&nbsp;&nbsp;&nbsp;=20
CORBA::String_var src =3D (const char*)"A string"; // Will make a copy =
of the=20
string</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D562082814-26111999></SPAN></FONT><FONT=20
face=3DArial size=3D2><SPAN =
class=3D562082814-26111999>&nbsp;&nbsp;&nbsp;=20
</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D562082814-26111999>&nbsp;&nbsp;&nbsp;=20
return CORBA::string_dup(src); // Will return a copy of =
src</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D562082814-26111999></SPAN></FONT><FONT=20
face=3DArial size=3D2><SPAN=20
class=3D562082814-26111999>}</SPAN></FONT></DIV></SPAN></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D562082814-26111999>Guy=20
Trudel</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D562082814-26111999></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;</FONT></SPAN><FONT =
face=3DTahoma=20
size=3D2>-----Original Message-----<BR><B>From:</B> Jeffrey Du=20
[mailto:jeffdu@163.net]<BR><B>Sent:</B> Saturday, December 04, 1999 =
11:26=20
PM<BR><B>To:</B> omniorb-list@uk.research.att.com<BR><B>Subject:</B> =
[omniORB]=20
Problem of CORBA::String in MFC Application<BR><BR></DIV></DIV>
<BLOCKQUOTE style=3D"MARGIN-RIGHT: 0px"></FONT>
  <DIV>
  <DIV><FONT size=3D2>&nbsp;&nbsp; I am writing a CORBA program in VC++ =
5.0 using=20
  omniORB 2.8 in Windows95. I find that</FONT></DIV>
  <DIV><FONT size=3D2>any functions in my program using CORBA::String =
will=20
  encounter an error when they return.</FONT></DIV>
  <DIV><FONT size=3D2>For example, here is my code of the =
function:</FONT></DIV>
  <DIV><FONT size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT size=3D2>int CWSInfoApp::InitCorbaServer()</FONT></DIV>
  <DIV><FONT size=3D2></FONT><FONT size=3D2>{</FONT></DIV>
  <DIV><FONT size=3D2>&nbsp;&nbsp; ......</FONT>&nbsp;</DIV>
  <DIV><FONT size=3D2>&nbsp;&nbsp; CORBA::String_var p =3D=20
  orb-&gt;object_to_string(myobj);</FONT></DIV>
  <DIV><FONT size=3D2>&nbsp;&nbsp; ......</FONT>&nbsp;</DIV>
  <DIV><FONT size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT size=3D2>&nbsp;&nbsp; return(0); // an error occurs after=20
  return</FONT></DIV>
  <DIV><FONT size=3D2></FONT><FONT size=3D2>}</FONT></DIV>
  <DIV><FONT size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT size=3D2>&nbsp;&nbsp; And the error message =
is:</FONT></DIV>
  <DIV><FONT size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT size=3D2>&nbsp;&nbsp; Microsoft Visual C++ Debug =
Library</FONT></DIV>
  <DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Debug =
Assertion=20
  Failed</FONT></DIV>
  <DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Program:&nbsp;=20
  .....</FONT></DIV>
  <DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; File:=20
  dbgdel.cpp</FONT></DIV>
  <DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line:=20
  47</FONT></DIV>
  <DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Exception:=20
  _BLOCK_TYPE_IS_VALID(pHead-&gt;nBlockUse)</FONT></DIV>
  <DIV><FONT size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT size=3D2>&nbsp;&nbsp; I think the error occurs when =
releasing=20
  CORBA::String memory. </FONT></DIV>
  <DIV><FONT size=3D2>&nbsp;&nbsp; Please tell me how to solve this=20
  problem.</FONT></DIV>
  <DIV><FONT size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT size=3D2>&nbsp;&nbsp; Jeffrey Du</FONT></DIV>
  <DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp; <A=20
  =
href=3D"mailto:jeffdu@163.net">jeffdu@163.net</A></FONT></DIV></DIV></BL=
OCKQUOTE></BODY></HTML>

------_=_NextPart_001_01BF381D.C7B0EF70--