On Fri, Apr 22, 2016 at 1:05 AM, Nicholas Nethercote <n.netherc...@gmail.com> wrote: > The third example I looked at was CycleCollectedJSRuntime. Again > problems, specifically this line in Init(): > > mOwningThread->SetScriptObserver(this);
Others have already said what I would have here generally, but this example is a good one to show. Note that this happens very early in a fairly complex initialization. In general, doing this sort of thing means that you have released a pointer to an incompletely initialized object. That means that whatever partial initialization might happen, all methods on the class need to handle the state the object might be in. It might be that this call could be deferred until after the fallible stuff happens, but I don't understand this code well-enough to know for certain. I certainly hope that the success of the Initialize function doesn't depend on receiving upcalls during the process. (As an aside, when I worked in Java, we had static analysis tools that prevented us from passing `this` to others during constructors. It's a nice rule to have.) _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform