Variables defined in web console can disappear with no warning

RESOLVED WORKSFORME

Status

DevTools
General
RESOLVED WORKSFORME
8 years ago
a month ago

People

(Reporter: jdm, Unassigned)

Tracking

unspecified
x86
Mac OS X

Firefox Tracking Flags

(blocking2.0 final+)

Details

(Reporter)

Description

8 years ago
Open a blank page, and open the web console.  Type |var f = document.createElement("iframe")|, then |f| to verify that f contains a value, and sit back and wait for (presumably) a GC to occur.  Type |f| in the console again, note that you now have "ReferenceError: f is not defined" instead of the previous value.
(Reporter)

Comment 1

8 years ago
This is a surprising and unfortunate user experience; I suspect blocking is in order.
blocking2.0: --- → ?
It's unfortunate for a lot of reasons!
(In reply to comment #0)
> Open a blank page, and open the web console.  Type |var f =
> document.createElement("iframe")|, then |f| to verify that f contains a value,
> and sit back and wait for (presumably) a GC to occur.  Type |f| in the console
> again, note that you now have "ReferenceError: f is not defined" instead of the
> previous value.

Could you retest with today's nightly? There were some changes made to evalInSandbox (oustanding wrapper+compartments fixes) last night that may have fixed this.

Updated

8 years ago
Blocks: 593957
(Reporter)

Comment 4

8 years ago
The error message has changed to "10:44:27.213: Error: Permission denied to access property 'f'" in today's nightly.
blocking2.0: ? → final+
curious to hear if this is still happening in current nightlies. I'm hoping the modifications to the evaluation code in bug 599940 have cured this.
(Reporter)

Comment 6

8 years ago
I tried to reproduce and no longer can.
Status: NEW → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → WORKSFORME
great success!

thanks for the follow-up.
For future generations, my theory as to what was happening, was that 

evalInSandbox(with(__helpers__) { with(__window__) { var a = Object; } });

Was executing | var a = Object | inside a separate scope from the sandbox itself. This allowed the garbage collector to detect that these variables were disconnected and clean them up.

The magic sauce was removing the always awful with() statements.
That should be quoted, as in:

evalInSandbox("with(__helpers__) { with(__window__) { var a = Object; } }");

(bugzilla needs a js parser)

Comment 10

8 years ago
let this be a lesson to us! 'with' is one of the "bad parts" of JS:)
(In reply to comment #10)
> let this be a lesson to us! 'with' is one of the "bad parts" of JS:)

I'm pretty sure I read that in a book somewhere. hmm...

Updated

a month ago
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.