This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

SIGSERV termination on return statement


Product Version = NetBeans IDE 7.2 (Build 201207171143)
Operating System = Windows 7 version 6.1 running on x86
Java; VM; Vendor = 1.7.0_03
Runtime = Java HotSpot(TM) Client VM 22.1-b02
Cygwin gcc 4.5.3
            gdb 4.5.3

I'm debugging my C++ software using Netbeans and gdb 4.5.3 (integrated into the 
IDE) and I get a fatal error on the return from a method. The fault is 
consistent in that there is a failure in the same place in my code with the same 
caller all the time, and inconsistent in that there is no failure under other 
conditions. I am perfectly willing to accept the fault as mine but I can't seem 
to find the fault with gdb (and, hence, unable to fix it). 


The circumstances are:

  when I have 'a = method()' with '=' overloaded there is always a failure on 
the method return.
  when I have 'method()' with no assignment there is no failure.

I have set a breakpoint in the overloaded assignment code but the breakpoint is 
never executed (?).

The code is shown below (as an aid?). Any idea how I can use gdb to isolate the 
point of failure? As a note, the overload architecture looks like:

class SlipCell {
   virtual SlipCell& operator=(SlipCell& X) = 0;
}

class SlipDatum: public SlipCell  {
  virtual SlipCell& operator=(SlipCell& X);  // code in .cpp file
}

class SlipHeader: public SlipCell  {
  virtual SlipCell^ operator=(SlipCell& X);  // code in .cpp file
}

class SlipSublist: public SlipCell  {
  virtual SlipCell& operator=(SlipCell& X);   // code in .cpp file
}

The code where the failure occurs is:
[code]
   SlipCell& SlipSublist::replace(SlipCell& X) {               // Replace a cell 
on a list with a new cell
      SlipCell& cell = *this;
      if (X.isData()) {
         cell = assignData(X); // failure before return to this statement from 
method
         delete this;
      } else { 
         *this = X;
      }
      return cell;
   }; // SlipCell& SlipSublist::replace(SlipCell& X)

   SlipCell& SlipSublist::assignData(SlipCell& X) {             // Assign a 
sublist to the current cell
      SlipCell* cell = this;
      if (isTemp()) {
         postError(SlipErr::E2036, "replace", "", "", this, &X);
      } else {
         
         if (X.isData()) {
            cell = &X;
            if (X.isTemp()) {
               cell = new SlipDatum((SlipDatum&)X);
            } else if (!X.isUnlinked()) {
               postError(SlipErr::E2039, "replace", "", "", this, &X);
               return *this;
            }
            replaceLinks(*cell);
            
         } else {
            SlipHeader* header    = &(SlipHeader&)X;
            SlipHeader* oldHeader = (SlipHeader*)*getSublistHeader();
            if (X.isSublist()) {
               header = (SlipHeader*)*getSublistHeader(X);
            } else if (!X.isHeader()) {
               postError(SlipErr::E3020, "replace", "", " Must be a Header, 
Sublist or Datum", this);
               return *cell;
            }
            *getSublistHeader() = header;
            (*getHeadRefCnt(*header))++;
            delete oldHeader;
         }
      }
      return *cell;  //failure seems to be after the return statement is 
executed and before the return
                        //to the caller and the overloaded '=' operator is never 
entered.
   }; // SlipCell& SlipSublist::assignData(SlipCell& X)
[/code]

I can't debug without a debugger. It would be useful to know that this is my 
error (I have misunderstood C++) or whether it is a debugger issue. And I would 
really like to know how to bypass any fault in the debugger (if there is one). 
This problem has dogged me for the last month or so - I have worked around it in 
most cases but now it's time to stop the bleeding.

thanks
PS: If my syntax is garbled or the presentation poor please provide guidance and 
not condemnation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]