Closed Bug 1454512 Opened 6 years ago Closed 6 years ago

rust is_symbol predicate broken on amd64

Categories

(Core :: JavaScript Engine, enhancement, P2)

x86_64
Unspecified
enhancement

Tracking

()

RESOLVED FIXED
mozilla61
Tracking Status
firefox61 --- fixed

People

(Reporter: terpri, Assigned: terpri)

Details

Attachments

(1 file, 1 obsolete file)

The is_symbol predicate in the Rust bindings doesn't work correctly on 64-bit systems. It compares the entire value against a shifted type tag, similar to the predicates for null and undefined, but it should ignore the value's payload (the symbol pointer).
Comment on attachment 8968357 [details] [diff] [review]
Fix JS::Value's is_symbol predicate.

Extract the type tag from the value in is_symbol and add a test case for it.
Attachment #8968357 - Flags: review?(sphink)
Comment on attachment 8968357 [details] [diff] [review]
Fix JS::Value's is_symbol predicate.

Review of attachment 8968357 [details] [diff] [review]:
-----------------------------------------------------------------

Nice, with a patch and everything. Thanks!

::: js/rust/tests/value.rs
@@ +26,5 @@
> +        );
> +        rooted!(in(cx) let mut rval = UndefinedValue());
> +        assert!(rt.evaluate_script(global.handle(), "Symbol('test')",
> +                                   "test", 1, rval.handle_mut()).is_ok());
> +        assert!(rval.is_symbol());

Can you add a negative test as well? A string seems best.
Attachment #8968357 - Flags: review?(sphink) → review+
Priority: -- → P2
Attachment #8968357 - Attachment is obsolete: true
(In reply to Steve Fink [:sfink] [:s:] (PTO Apr9-12) from comment #3)
> Comment on attachment 8968357 [details] [diff] [review]
> Fix JS::Value's is_symbol predicate.
> 
> Review of attachment 8968357 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> Nice, with a patch and everything. Thanks!
> 
> ::: js/rust/tests/value.rs
> @@ +26,5 @@
> > +        );
> > +        rooted!(in(cx) let mut rval = UndefinedValue());
> > +        assert!(rt.evaluate_script(global.handle(), "Symbol('test')",
> > +                                   "test", 1, rval.handle_mut()).is_ok());
> > +        assert!(rval.is_symbol());
> 
> Can you add a negative test as well? A string seems best.

Sure, added in the new patch. (the tests could also be merged into a single #[test] function if that is better style)
Attachment #8968768 - Flags: review?(sphink)
Attachment #8968768 - Flags: review?(sphink)
Attachment #8968768 - Flags: review+
Attachment #8968768 - Flags: checkin?
(In reply to Robin Templeton from comment #5)
> Sure, added in the new patch. (the tests could also be merged into a single
> #[test] function if that is better style)

I have no clue, I've never looked at a rust test before. I have no issue with landing this as-is, though. Thanks!
Assignee: nobody → robin
Comment on attachment 8968768 [details] [diff] [review]
Fix JS::Value's is_symbol predicate.

Please use checkin-needed, it works better with the automated bug marking tools.
Attachment #8968768 - Flags: checkin?
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/fd6fc6aa6448
Fix JS::Value's is_symbol predicate. r=sfink
https://hg.mozilla.org/mozilla-central/rev/fd6fc6aa6448
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: