Closed Bug 696220 Opened 13 years ago Closed 13 years ago

js1_8_5/extensions/reflect-parse.js is failing

Categories

(Core :: JavaScript Engine, defect)

Other Branch
x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla10

People

(Reporter: jorendorff, Assigned: jorendorff)

References

Details

Attachments

(1 file)

The location information is bogus. Valgrind finds uninitialized memory reads. I have a fix.
Attached patch v1Splinter Review
Assignee: general → jorendorff
Attachment #568521 - Flags: review?(luke)
Here's what happened here.

struct TokenPos previously had no constructors declared. I added this:
    TokenPos() {}

But there is a struct Token that includes a TokenPos, and a class TokenStream
that has a member `Token tokens[N];'. TokenStream's constructor did this:
      : tokens()

This apparently had the effect of zeroing out all the members of each Token, though I have a hard time constructing a mental model of C++ in which that makes any sense... By adding the do-nothing constructor, I changed the meaning from "fill with zeroes" to "don't initialize".

We um... we probably shouldn't be depending on that, but for today let's just restore the status quo rather than charging forward unwarily.
See bug 588061. If only jsreflect.cpp needs zero-init, and only of the not-yet-got "first token", we should hack only that file, or find a better fix for bug 588061.

/be
(In reply to Jason Orendorff [:jorendorff] from comment #2)
> This apparently had the effect of zeroing out all the members of each Token,
> though I have a hard time constructing a mental model of C++ in which that
> makes any sense... By adding the do-nothing constructor, I changed the
> meaning from "fill with zeroes" to "don't initialize".

To wit, (8.5.10) "An object whose initializer is an empty set of parenthesis, i.e., (), shall be value-initialized."  8.5.7 then specifies value-initialization to be: if you don't have a user-provided constructor, your zero-initialize your members and, if you do, then you just call the user-provided constructor without zero-initialization.
Comment on attachment 568521 [details] [diff] [review]
v1

Oops, didn't see the r?.
Attachment #568521 - Flags: review?(luke) → review+
https://hg.mozilla.org/mozilla-central/rev/9fa6410c1a3a
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla10
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: