octave-maintainers
[Top][All Lists]
Advanced

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

Re: Question


From: Chuck Robey
Subject: Re: Question
Date: Tue, 19 May 1998 13:01:21 -0400 (EDT)

On Sat, 16 May 1998, John W. Eaton wrote:

> On 15-May-1998, Chuck Robey <address@hidden> wrote:
> |     196 #endif
> |     197 
> |     198   Vprogram_invocation_name = name;
> |     199   size_t pos = Vprogram_invocation_name.rfind ('/');
> |     200   Vprogram_name = (pos == NPOS)
> | 
> | This calls, indirectly, to libstdc++/std/bastring.cc line 147:
> | 
> |     146 // _lib.string.cons_ construct/copy/destroy:
> |     147   basic_string& operator= (const basic_string& str)
> |     148     {
> |     149       if (&str != this) { rep ()->release (); dat = str.rep()->grab 
> (); }
> |     150       return *this;
> |     151     }
> | 
> | The release function is in bastring.h line 69:
> | 
> |      67   charT& operator[] (size_t s) { return data () [s]; }
> |      68   charT* grab () { if (selfish) return clone (); ++ref; return data 
> ();}   
> |      69   void release () { if (--ref == 0) delete this; }
> |      70   
> |      71   inline static void * operator new (size_t, size_t);
> | 
> | I'm not sure about this, but on entering the function, ref is 1, and
> | that's the value of this.ref, right?  (understand please that I could be
> | stronger perhaps in C++, sorry).  It _looks_ like "this" is being
> | deleted, then immediately referenced, which would sure cause the SIGBUS.
> 
> I believe that the `this' that's being deleted is a __bsrep object,
> not a basic_string object.

I've not dropped this.  I just found that if I add the qualifier
"string" to the variables like in line 198 above (and several after) it
no longer gets the SIGBUS.  I still am getting a SIGBUS at line 211,
which I modified:

    210   char *hd = getenv ("HOME");
    211   string Vhome_directory = hd ? hd : "I have no home!";

I don't know why this is yet, and I haven't finished looking at why
string works for sure.  What is happening is that during the operator= a
release is done, but the "this" at that point is bogus, which causes the
SIGBUS.  I'm not sure, it might be the instruction before the release,
it's all inline, and gdb isn't clear on when it's happening.  The "this"
is bogus, tho.

----------------------------+-----------------------------------------------
Chuck Robey                 | Interests include any kind of voice or data 
address@hidden         | communications topic, C programming, and Unix.
213 Lakeside Drive Apt T-1  |
Greenbelt, MD 20770         | I run Journey2 and picnic (FreeBSD-current)
(301) 220-2114              | and jaunt (NetBSD).
----------------------------+-----------------------------------------------






reply via email to

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