`free` operator

Yehuda Katz wycats at gmail.com
Fri Oct 26 13:19:43 PDT 2012


An optimal debugger would show the textual location in the source code
where live references to a particular object were created. Optimally, it
would be possible to get the references during debug mode via the "tooltip"
that comes up when hovering over a variable.

Isaac could then solve his problem trivially by adding a debugger where he
would have called free and look at what other places in the source are
still holding references.

On Fri, Oct 26, 2012 at 12:34 PM, John J Barton <johnjbarton at johnjbarton.com
> wrote:

> On Fri, Oct 26, 2012 at 11:58 AM, Isaac Schlueter <i at izs.me> wrote:
> > So, yes, you can certainly use debugging tools to find which objects
> > are leaking.  But, there are times when you have a program where
> > something is leaking, and you read through the code, and see that
> > there is no possible way that it could be leaking (but it is, as
> > reality sometimes stubbornly refuses to be told what to do.)
> >
> > Use-after-free bugs are not great, but they are relatively easy to
> > track down.  And, in general, a program that crashes when it does
> > something wrong, is handling it exactly right.  Slowly leaking memory
> > is much harder to diagnose, and usually much harder to correct.
> ...
> >
> > Yehuda's "action at a distance" complaint is definitely a valid
> > concern.  However, note that an object can't be freed unless you have
> > a reference to the object.  Thus, any code that would set my reference
> > to undefined could only do so if it was also capable of mutating the
> > object in any other way (adding/removing properties, etc.)
> >
> > So, we already have this:
> >
> > function () {
> > // acquire a ref from some external code
> > // no way of knowing what else is sharing this object
> > var x = func()
> > x.foo = 'bar'
> > // other code...
> > doAnotherThing()
> > // not guaranteed!
> > assert(x.foo === 'bar')
>
> FWIW, Querypoint debugging will be able to tell you "where was x.foo
> changed?".
>
> > }
> >
> > Whenever you have a reference to an object that is shared with some
> > other code, there's the potential for action at a distance.
>
> Seems like other questions we'd like to answer include "where was the
> object refed by 'x' defined?" "Where are other references to that
> object taken?" "Where was any property of 'x' written?" These seem
> feasible.
>
> jjb
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>



-- 
Yehuda Katz
(ph) 718.877.1325
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121026/0b3353d8/attachment.html>


More information about the es-discuss mailing list