Finalizer no longer called

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Finalizer no longer called

Anthony Catel-4
Hi,

Does anyone know if there was a change related to Finalizer/GC during
JS_DestroyContext/Runtime?
It looks like that Finalizer are no longer called on object when
destroying a context.

It was working on mozilla-central 2 month ago. Using the last MC seems
to break this behaviour :

- The GC is called
- No finalizer called on (non rooted) objects living on the script
land.

Thanks,

Anthony C.
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: Finalizer no longer called

Dave Mandelin-3
I'm not aware of an intentional change. If you could bisect to the rev where it changed it might not be too hard to find out why and/or revert it.

Dave
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: Finalizer no longer called

Anthony Catel-4
Hey David,

I'm still not sure but :

http://pastebin.mozilla.org/2078974

I see no solution apart from keeping track on every rooted object.
In the exemple above, |createPattern| finalizer is supposed to unroot
"i". BTW it's not called because "i" is rooted. Also, NO finalizer got
called if there are remaining rooted object (like the |File| object in
the exemple). However |File| is finalized if it's create in a function
(not on the global).

Looks like a bug to me.
Or am I thinking wrong?

Le 2013-01-11 02:33, Dave Mandelin a écrit :
> I'm not aware of an intentional change. If you could bisect to the
> rev where it changed it might not be too hard to find out why and/or
> revert it.
>
> Dave
> _______________________________________________
> dev-tech-js-engine mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine

_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: Finalizer no longer called

Boris Zbarsky
In reply to this post by Dave Mandelin-3
On 1/22/13 5:45 PM, [hidden email] wrote:
> I'm still not sure but :
>
> http://pastebin.mozilla.org/2078974

So if this is running in global scope, it's adding properties called
"i", "pattern", and "f" to the global, and making them point to an
HTMLImageElement, a pattern, and a File.

> I see no solution apart from keeping track on every rooted object.
> In the exemple above, |createPattern| finalizer is supposed to unroot
> "i".

I'm not sure what that means...

> BTW it's not called because "i" is rooted.

Not called when?  Ever?

If the code above runs at global scope, then none of the objects
involved can be destroyed until either the "i", "pattern", and "f"
properties of the global are pointed to different objects or the global
itself is GCed.

> However |File| is finalized if it's create in a function
> (not on the global).

If the above code were in a function, then "i", "pattern", and "f" would
be function-local variables that would stop pointing to things after the
function returns (modulo closures, etc), right?

-Boris
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: Finalizer no longer called

Anthony Catel-4
Hi Boris,

It's not running on a Browser. "new Image()" is just an exemple.
The problem is :

var i = new Object_a();
pattern = Object2(i);

Object2() store a reference to the "i" JSObject and calls
JS_AddObjectRoot().

Now, during a JS_DestroyContext/runtime(), pattern is not finalized,
(it's not rooted).
And more, no object got collected during the destroy.

My design is :
1. Object2 constructor : store Object_a's JSObject + JS_AddObjectRoot
2. Object2 destructor called by Object2's finalizer :
JS_RemoveObjectRoot

Now, since 2. is not triggered (because of JS_AddObjectRoot).

I don't know, but JS_DestroyContext should finalize everyting regarless
of there rooting.

Le 2013-01-22 23:55, Boris Zbarsky a écrit :

> On 1/22/13 5:45 PM, [hidden email] wrote:
>> I'm still not sure but :
>>
>> http://pastebin.mozilla.org/2078974
>
> So if this is running in global scope, it's adding properties called
> "i", "pattern", and "f" to the global, and making them point to an
> HTMLImageElement, a pattern, and a File.
>
>> I see no solution apart from keeping track on every rooted object.
>> In the exemple above, |createPattern| finalizer is supposed to
>> unroot
>> "i".
>
> I'm not sure what that means...
>
>> BTW it's not called because "i" is rooted.
>
> Not called when?  Ever?
>
> If the code above runs at global scope, then none of the objects
> involved can be destroyed until either the "i", "pattern", and "f"
> properties of the global are pointed to different objects or the
> global itself is GCed.
>
>> However |File| is finalized if it's create in a function
>> (not on the global).
>
> If the above code were in a function, then "i", "pattern", and "f"
> would be function-local variables that would stop pointing to things
> after the function returns (modulo closures, etc), right?
>
> -Boris
> _______________________________________________
> dev-tech-js-engine mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine

_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: Finalizer no longer called

Wes Garland
On 22 January 2013 18:21, <[hidden email]> wrote:

> I don't know, but JS_DestroyContext should finalize everyting regarless of
> there rooting.
>

Have you tried removing the global object's root (maybe with the
JS_SetGlobalObject(cx,  NULL) ?)  and then running JS_GC?

It's possible that context shutdown might shortcut this... it shouldn't,
but I vaguely seem to remember a bug in GPSEE long ago related to this.

But I agree, everything should be finalized, because when you destroy the
context, you are removing all roots, and hopefully running the garbage
collector!   Not doing so can cause bugs with native objects which hold OS
resources open.

Wes

Le 2013-01-22 23:55, Boris Zbarsky a écrit :

>
>  On 1/22/13 5:45 PM, [hidden email] wrote:
>>
>>> I'm still not sure but :
>>>
>>> http://pastebin.mozilla.org/**2078974<http://pastebin.mozilla.org/2078974>
>>>
>>
>> So if this is running in global scope, it's adding properties called
>> "i", "pattern", and "f" to the global, and making them point to an
>> HTMLImageElement, a pattern, and a File.
>>
>>  I see no solution apart from keeping track on every rooted object.
>>> In the exemple above, |createPattern| finalizer is supposed to unroot
>>> "i".
>>>
>>
>> I'm not sure what that means...
>>
>>  BTW it's not called because "i" is rooted.
>>>
>>
>> Not called when?  Ever?
>>
>> If the code above runs at global scope, then none of the objects
>> involved can be destroyed until either the "i", "pattern", and "f"
>> properties of the global are pointed to different objects or the
>> global itself is GCed.
>>
>>  However |File| is finalized if it's create in a function
>>> (not on the global).
>>>
>>
>> If the above code were in a function, then "i", "pattern", and "f"
>> would be function-local variables that would stop pointing to things
>> after the function returns (modulo closures, etc), right?
>>
>> -Boris
>> ______________________________**_________________
>> dev-tech-js-engine mailing list
>> dev-tech-js-engine@lists.**mozilla.org<[hidden email]>
>> https://lists.mozilla.org/**listinfo/dev-tech-js-engine<https://lists.mozilla.org/listinfo/dev-tech-js-engine>
>>
>
> ______________________________**_________________
> dev-tech-js-engine mailing list
> dev-tech-js-engine@lists.**mozilla.org<[hidden email]>
> https://lists.mozilla.org/**listinfo/dev-tech-js-engine<https://lists.mozilla.org/listinfo/dev-tech-js-engine>
>



--
Wesley W. Garland
Director, Product Development
PageMail, Inc.
+1 613 542 2787 x 102
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: Finalizer no longer called

Boris Zbarsky
In reply to this post by Anthony Catel-4
On 1/23/13 8:51 AM, Wes Garland wrote:
> because when you destroy the
> context, you are removing all roots

Uh... no.  Why would that be true?

-Boris
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: Finalizer no longer called

Anthony Catel-4
In reply to this post by Wes Garland
Hey Wes,

We found that calling JS_SetAllNonReservedSlotsToUndefined on the
global object is the right solution.
Details here :

https://bugzilla.mozilla.org/show_bug.cgi?id=716981#c9

I'm still having concerns though
(https://bugzilla.mozilla.org/show_bug.cgi?id=716981#c10)

Anthony

Le 2013-01-23 14:51, Wes Garland a écrit :

> On 22 January 2013 18:21, <[hidden email]> wrote:
>
>> I don't know, but JS_DestroyContext should finalize everyting
>> regarless of there rooting.
>
> Have you tried removing the global object's root (maybe with the
> JS_SetGlobalObject(cx,  NULL) ?)  and then running JS_GC?
>
> It's possible that context shutdown might shortcut this... it
> shouldn't, but I vaguely seem to remember a bug in GPSEE long ago
> related to this.
>
> But I agree, everything should be finalized, because when you destroy
> the context, you are removing all roots, and hopefully running the
> garbage collector!   Not doing so can cause bugs with native objects
> which hold OS resources open.
>
> Wes
>
>> Le 2013-01-22 23:55, Boris Zbarsky a écrit :
>>
>>> On 1/22/13 5:45 PM, [hidden email] wrote:
>>>
>>>> I'm still not sure but :
>>>>
>>>> http://pastebin.mozilla.org/2078974 [1]
>>>
>>> So if this is running in global scope, it's adding properties
>>> called
>>> "i", "pattern", and "f" to the global, and making them point to an
>>> HTMLImageElement, a pattern, and a File.
>>>
>>>> I see no solution apart from keeping track on every rooted object.
>>>> In the exemple above, |createPattern| finalizer is supposed to
>>>> unroot
>>>> "i".
>>>
>>> I'm not sure what that means...
>>>
>>> BTW it's not called because "i" is rooted.
>>>
>>>> bjects
>>>> involved can be destroyed until either the "i&q
>>> attern", and "f"
>>> properties of the global are pointed to different objects or the
>>> global itself is GCed.
>>>
>>> However |File| is finalized if it's create in a function
>>> (not on the global).
>>>
>>> If the above code were in a function, then "i", "pat
>>>
>>>> s
>>>> after the function returns (modulo closures, etc), right?
>>>>
>>>> -Boris
>>>> ______
>>> ____________________________
>>> dev-tech-js-engine mailing list
>>> [hidden email]
>>> https://lists.mozilla.org/listinfo/dev-tech-js-engine [2]
>>
>> _______________________________________________
>> dev-tech-js-engine mailing list
>> [hidden email]
>> https://lists.mozilla.org/listinfo/dev-tech-js-engine [2]
>
> --
> Wesley W. Garland
> Director, Product Development
> PageMail, Inc.
> +1 613 542 2787 x 102
>
> Links:
> ------
> [1] http://pastebin.mozilla.org/2078974
> [2] https://lists.mozilla.org/listinfo/dev-tech-js-engine

_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: Finalizer no longer called

Wes Garland
In reply to this post by Boris Zbarsky
On 23 January 2013 09:06, Boris Zbarsky <[hidden email]> wrote:

> On 1/23/13 8:51 AM, Wes Garland wrote:
>
>> because when you destroy the
>> context, you are removing all roots
>>
>
> Uh... no.  Why would that be true?
>

Sorry, I should have said "when you destroy the ONLY context" -- which I
suppose may not be true in Anthony's case.

Wes
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine