[omniORB] crash when transmitting NULL pointer in IDL method parm

EDWARD_LIN edward_lin@iwin.com.tw
Fri Nov 29 11:43:01 2002


Hi, Hartmut Raschick

-- You must use --

NotificationClient_var cbObj;
howDidItGo =
topoIF->setAttr(objAddr,attrIDList,rwModes,aValUnionList,cbObj,trxID);
// much better if you us "cbObj.in()"

-- or --

NotificationClient_ptr cbObj = NotificationClient::_nil();
howDidItGo =
topoIF->setAttr(objAddr,attrIDList,rwModes,aValUnionList,cbObj,trxID);

According to OMG spec., omniORB is right, you can not use NULL or 0 to
indicate or test nil reference, the proper and portable way is to use _nil()
and is_nil() helper functions.

If some ORB's don't complain your code, they are wrong and not portable,
since _ptr_type reference mustn't be C++ pointer.

Best Regards,
Edward


----- Original Message -----
From: "Hartmut Raschick" <hartmut.raschick@ke-elektronik.de>
To: <omniorb-list@omniorb-support.com>
Sent: Friday, November 29, 2002 3:23 PM
Subject: [omniORB] crash when transmitting NULL pointer in IDL method parm


> Consider:
>
> --snip---------------------------------------------------
> ...
>   interface Topology {
> ...
>     boolean setAttr( in  ObjAddr               aObjAddr,
>                      in  AttrIdList            aAttrIdList,
>                      in  AttrReadWriteModeList aAttrReadWriteModeList,
>                      in  AttrValUnionList      aAttrValUnionList,
>                      in  NotificationClient    aNotificationClient,
>                      out long                  aTransactionId )
>       raises( NoSuchObj,
>               NoSuchAttr );
> ...
> --snap---------------------------------------------------
>
> and
>
> --snip---------------------------------------------------
> ...
>   NotificationClient_ptr cbObj = NULL;
> ...
>           howDidItGo = topoIF->setAttr(objAddr, attrIDList, rwModes,
>                                        aValUnionList, cbObj, trxID);
> ...
> --snap---------------------------------------------------
> this crashes because no-one tests for cbObj (not) being NULL
>
>
> OMNI4 does (from-idl generated code):
> --snip---------------------------------------------------
> inline void
> NotificationClient::_marshalObjRef(::NotificationClient_ptr obj,
cdrStream& s) {
>   omniObjRef::_marshal(obj->_PR_getobj(),s);
> }
> --snap---------------------------------------------------
> (assumes correct pointer ... :( )
>
>
> whereas OMNI3 did (from-idl generated code):
> --snip---------------------------------------------------
> inline void
> NotificationClient::_marshalObjRef(NotificationClient_ptr obj,
> NetBufferedStream& s) {
>   CORBA::MarshalObjRef(obj, _PD_repoId, 35, s);
> }
> --snap---------------------------------------------------
>
> which was (${OMNI_DIR}/src/lib/omniORB2/orbcore/corbaOrb.cc):
> --snip---------------------------------------------------
> void
> CORBA::MarshalObjRef(CORBA::Object_ptr obj, const char* repoId,
>                      size_t repoIdSize, NetBufferedStream& s)
> {
>   if (CORBA::is_nil(obj)) {
>     // nil object reference
>     ::operator>>= ((CORBA::ULong)1,s);
>     ::operator>>= ((CORBA::Char) '\0',s);
>     ::operator>>= ((CORBA::ULong) 0,s);
>     return;
>   }
>
>   // non-nil object reference
>   repoId = obj->_PR_getobj()->_mostDerivedRepoId();
> --snap---------------------------------------------------
> which, as one can see, tested for nil-ness... good...
>
> to forestall the question: NULL pointer means: just (try to) set attr(s),
> I don't care for the result...
> has this happended to anyone else? what do you say? should one call
> this a... bug?!
>
> N.B.: I shouldnt say this here, I know, but... other orbs also don't
>       panic there...
>
> P.S.: The principal mark of genius is not perfection but originality,
>       the opening of new frontiers.
>          - Arthur Koestler (1905-1983)
> P.P.S.: So it's OK, I suppose... :)
>
> --
> Hartmut "Hardy" Raschick / Dept. RD41
> ke Kommunikations-Elektronik GmbH
> Wohlenberstr. 3, 30179 Hannover
> Phone: ++49 (0)511 6747-564
> Fax: ++49 (0)511 6747-340
> e-Mail: hartmut.raschick@ke-elektronik.de
> http://www.ke-elektronik.de
> _______________________________________________
> omniORB-list mailing list
> omniORB-list@omniorb-support.com
> http://www.omniorb-support.com/mailman/listinfo/omniorb-list
>