help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cell array and 2.1.57


From: Al Niessner
Subject: Cell array and 2.1.57
Date: Fri, 09 Apr 2004 08:48:15 -0700

I have just upgraded from 2.1.52 to 2.1.57 and found Cell to be broken.
Attached are a test program (dld) for Cell that shows the problem
(testCell.cc) and the gdb output (gdb.bktrace) which shows the actual
error. I believe a NULL dereference is happening at ov.h:265, but would
like the experts to advise before I go patching code as core as this. I
have searched this mailing list and found no references to this problem.

>From a cursory understanding of how octave is put together, it seems as
though an octave_value is not being built correctly and 'rep' is NULL
but never tested for in ov.h:261-273 inclusive:

octave_value& operator = (const octave_value& a)
{
  if (rep != a.rep)
    {
      if (--rep->count == 0) delete rep;

      rep = a.rep;
      rep->count++;
    }
  return *this;
}
                                                                                
A simple change to correct this would be to test if 'rep' is NULl and if it is 
then assign it a.rep and increment count. In terms of code:

octave_value& operator = (const octave_value& a)
{
  if (rep == NULL)
    {
      rep = a.rep;
      rep->count++;
    }

  if (rep != a.rep)
    {
      if (--rep->count == 0) delete rep;

      rep = a.rep;
      rep->count++;
    }
  return *this;
}

Even though this appears correct, I am concerned that it may be in
conflict with octave's fundamental architecture and the problem should
be repaired in some other way.

Of course, the other possibility is that the desired mechanism for
adding to a Cell array is no longer:

Cell something;
something(0) = std::string("Some value in string form");

If that is so, then I did not find the new mechanism to be easily
derivable from Cell.h.

Thanks for all the help in advance.
 

-- 
Al Niessner <address@hidden>
Jet Propulsion Laboratory

All opinions stated above are mine and do not necessarily reflect 
those of JPL or NASA.

 ----
| dS | >= 0
 ----

Attachment: testCell.cc
Description: Text Data

Attachment: gdb.bktrace
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]