Closed Bug 494544 Opened 15 years ago Closed 15 years ago

Uninitialized variable undefined after assignment whose initializer is a closure capturing that var

Categories

(Core :: JavaScript Engine, defect, P1)

defect

Tracking

()

VERIFIED FIXED
mozilla1.9.2a1

People

(Reporter: Mardak, Assigned: brendan)

References

()

Details

(Keywords: verified1.9.1, Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file, 2 obsolete files)

I'm getting some strange behavior when I use a <script> tag with version=1.8 but running the code in the command line shell, it works fine.

data:text/html,<script type="text/javascript;version=1.8">
let (foo) {
  foo = { get bar() foo };
  alert([typeof foo, typeof foo.bar])
}</script>

In the shell I get "object, object" but in the browser I get "object, undefined".


It seems to be triggered by the lack of assignment because when I do..

let (foo = 0) {

everything is happy.
See also bug 494518.
Blocks: 494518
Assignee: general → brendan
Blocks: 489034
No longer blocks: 494518
Status: NEW → ASSIGNED
Priority: -- → P1
Target Milestone: --- → mozilla1.9.1
Flags: blocking1.9.1?
This links the blocking chain up correctly. The primal sin is the optimization of an uninitialized declaration, followed in the same block by an assignment whose lvalue is the first use of the decl's def, to be equated to an initialized decl.

Since we use source coordinates in judging dominance, the assignment imputed as an initialization has to be "covered" by the start/end position of the decl, in order to include the rvalue (the right-hand side of the assignment, which could contain the closure whose upvar refers to the decl -- foo in this case).

Patch shortly, need to figure out how to get this right without losing the safe optimization.

This should block 1.9.1.

/be
Attached patch fix (obsolete) — Splinter Review
Attachment #379318 - Flags: review?(mrbkap)
Applied patch and getting a segfault on start :

./run-mozilla.sh: line 131: 18597 Segmentation fault "$prog" ${1+"$@"}
Can you get a stack?  It's probably something small, given the size of the patch. :)
Attached patch fix, v2 (obsolete) — Splinter Review
Frederic: My firefox build started, but perhaps you have an extension I don't. I'd love to see a stack from your crash; if you can use -g to debug, find me on IRC while in gdb -- even better. And please try this patch, it may fix whatever it was that caused the crash you saw.

/be
Attachment #379318 - Attachment is obsolete: true
Attachment #379357 - Flags: review?(mrbkap)
Attachment #379318 - Flags: review?(mrbkap)
Flags: in-testsuite?
Here is my crash with first fix :

./run-mozilla.sh -g ./firefox-bin
MOZILLA_FIVE_HOME=.
  LD_LIBRARY_PATH=.:./plugins:.
DISPLAY=:0.0
DYLD_LIBRARY_PATH=.:.
     LIBRARY_PATH=.:./components:.
       SHLIB_PATH=.:.
          LIBPATH=.:.
       ADDON_PATH=.
      MOZ_PROGRAM=./firefox-bin
      MOZ_TOOLKIT=
        moz_debug=1
     moz_debugger=
which: no ddd in (/bin:/usr/bin:/sbin:/usr/sbin:/usr/bin/perlbin/site:/usr/bin/perlbin/vendor:/usr/bin/perlbin/core:/usr/local/bin)
/usr/bin/gdb ./firefox-bin -x /tmp/mozargs.QsUG6N
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu"...
(no debugging symbols found)
(gdb) run
Starting program: /home/fred/logs/fox/objdir-fx/dist/bin/firefox-bin 
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
---Type <return> to continue, or q <return> to quit---
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
---Type <return> to continue, or q <return> to quit---
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0x7fac84c28760 (LWP 12265)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
---Type <return> to continue, or q <return> to quit---
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
---Type <return> to continue, or q <return> to quit---
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0x7fac749ff910 (LWP 12268)]
[New Thread 0x7fac741fe910 (LWP 12269)]
[New Thread 0x7fac739fd910 (LWP 12270)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0x7fac710fd910 (LWP 12271)]
[Thread 0x7fac710fd910 (LWP 12271) exited]
[New Thread 0x7fac710fd910 (LWP 12272)]
[Thread 0x7fac741fe910 (LWP 12269) exited]
---Type <return> to continue, or q <return> to quit---
(no debugging symbols found)
[Thread 0x7fac710fd910 (LWP 12272) exited]
[Thread 0x7fac739fd910 (LWP 12270) exited]
[Thread 0x7fac749ff910 (LWP 12268) exited]
[New process 12265]
Executing new program: /home/fred/logs/fox/objdir-fx/dist/bin/firefox-bin
(no debugging symbols found)
warning: Cannot initialize thread debugging library: generic error
(no debugging symbols found)
[New process 12265]
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
---Type <return> to continue, or q <return> to quit---
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
---Type <return> to continue, or q <return> to quit---
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
./run-mozilla.sh: line 182: 12264 Erreur de segmentation  $debugger "$prog" -x $tmpfile

Will try fix2 asap.
Forgot to add : no extensions at all.
Summary: Unassigned let block variables are undefined after assignment for <script> code → Uninitialized variable undefined after assignment whose initializer is a closure capturing that var
With 2nd fix, I can make firefox - debug build - run. Weird.

Anyway, here is the log I have :

./run-mozilla.sh -g ./firefox-bin
MOZILLA_FIVE_HOME=.
  LD_LIBRARY_PATH=.:./plugins:.
DISPLAY=:0.0
DYLD_LIBRARY_PATH=.:.
     LIBRARY_PATH=.:./components:.
       SHLIB_PATH=.:.
          LIBPATH=.:.
       ADDON_PATH=.
      MOZ_PROGRAM=./firefox-bin
      MOZ_TOOLKIT=
        moz_debug=1
     moz_debugger=
which: no ddd in (/bin:/usr/bin:/sbin:/usr/sbin:/usr/bin/perlbin/site:/usr/bin/perlbin/vendor:/usr/bin/perlbin/core:/usr/local/bin)
/usr/bin/gdb ./firefox-bin -x /tmp/mozargs.EMcXhl
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu"...
(no debugging symbols found)
(gdb) 
(gdb) run
Starting program: /home/fred/logs/fox/objdir-fx/dist/bin/firefox-bin 
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
---Type <return> to continue, or q <return> to quit---
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
---Type <return> to continue, or q <return> to quit---
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0x7ff500335760 (LWP 21399)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
---Type <return> to continue, or q <return> to quit---
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
---Type <return> to continue, or q <return> to quit---
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0x7ff4f00ff910 (LWP 21402)]
[New Thread 0x7ff4ef8fe910 (LWP 21403)]
[New Thread 0x7ff4ef0fd910 (LWP 21404)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0x7ff4ec7fd910 (LWP 21405)]
[Thread 0x7ff4ec7fd910 (LWP 21405) exited]
[New Thread 0x7ff4ec7fd910 (LWP 21406)]
[Thread 0x7ff4ef8fe910 (LWP 21403) exited]
---Type <return> to continue, or q <return> to quit---
(no debugging symbols found)
[Thread 0x7ff4ec7fd910 (LWP 21406) exited]
[Thread 0x7ff4ef0fd910 (LWP 21404) exited]
[Thread 0x7ff4f00ff910 (LWP 21402) exited]
[New process 21399]
Executing new program: /home/fred/logs/fox/objdir-fx/dist/bin/firefox-bin
(no debugging symbols found)
warning: Cannot initialize thread debugging library: generic error
(no debugging symbols found)
[New process 21399]
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
---Type <return> to continue, or q <return> to quit---
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
---Type <return> to continue, or q <return> to quit---
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
./run-mozilla.sh: line 182: 21398 Erreur de segmentation  $debugger "$prog" -x $tmpfile
Attachment #379357 - Flags: review?(mrbkap) → review+
Carrying over r+.

/be
Attachment #379357 - Attachment is obsolete: true
Attachment #379360 - Flags: review+
http://hg.mozilla.org/tracemonkey/rev/0463edf878f6

/be
Whiteboard: fixed-in-tracemonkey
Flags: blocking1.9.1? → blocking1.9.1+
http://hg.mozilla.org/mozilla-central/rev/0463edf878f6
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Verified fixed on trunk with builds on all platforms like Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2a1pre) Gecko/20090525 Minefield/3.6a1pre ID:20090525031110
Status: RESOLVED → VERIFIED
Target Milestone: mozilla1.9.1 → mozilla1.9.2a1
Hope this is helpful! As I've just commented on Bug #494199, I'm still seeing, in Seamonkey latest nightly, the Yahoo mail problem of selected categories being highlighted but not opening.
Fixed in latest hourly. Great work.
Verified fixed on 1.9.1 with builds on all platforms like: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1pre) Gecko/20090601 Shiretoko/3.5pre ID:20090601031153
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: