[PyKDE] SEGV with SIP generated code.

Bjorn Pettersen BPettersen at narex.com
Fri May 17 02:00:01 BST 2002


I've got the following basic setup:

  class NAcctGrpVTSLCon {
  ...
  };

  clas NAcctCon {
  %HeaderCode
  #include <acct/NAcctCon.h>
  %End	
  public:
    NAcctCon();
    NAcctGrpVTSLCon* getAcctGrp();
  };

and Python code that does:

  acct = NrxDataTypes.NAcctCon()
  acctGrp = acct.getAcctGrp()

when it calls getAcctGrp() in the second line, it goes into the SIP
generated method and then calls

  if
(sipParseArgs(&sipArgsParsed,sipArgs,"m",sipThisObj,sipClass_NAcctCon,&s
ipCpp))

which eventually calls "parsePass2", which in turn calls "sipGetCppPtr".
This function is defined as

  const void *sipGetCppPtr(sipThisType *w,PyObject *toClass)
  {
    const void *ptr;
    if (sipIsAccessFunc(w)) {
       ptr = (*w -> u.afPtr)();
    } else if (sipIsIndirect(w)) {
       printf("cppPtr: %d\n", (int)w->u.cppPtr);     !!!
       ptr = *((const void **)w -> u.cppPtr);
    } else {
       ptr = w -> u.cppPtr;
    }
    if (checkPointer(ptr) < 0)
       return NULL;
    return (*w -> xType -> castfunc)(ptr,toClass);
  }

(with braces added by me for debugging). At the !!! the printf outputs
'6', and the following call (i.e. dereference) causes a SEGV/GPF.

I'm guessing the this pointer for NAcctCon didn't get set or get
overwritten somehow, but I can't figure out how... Any pointers?

-- bjorn




More information about the PyQt mailing list