Skip to content

Negative zero broken on ≥ v10.4.0 #25221

Description

@TimothyGu
  • Version: ≥ v10.4.0 < v12.0.0
  • Platform: Linux 4.9.0-8-amd64 SMP Debian 4.9.130-2 (2018-10-27) x86_64 GNU/Linux
  • Subsystem: v8

V8 versions between 6.7 and 7.0 (inclusive) have a bug where

[...[]];
console.log(Object.is(-0, 0));

prints true rather than false. This is reproducible with all Node.js versions after 10.4.0, though it is fixed on master which uses V8 7.1. We should find the V8 commit that fixes this and backport it to LTS at the very least.

/cc @devsnek, who helped triage this bug
/cc @nodejs/v8

Activity

  1. added a commit that references this issue on Dec 26, 2018
  2. devsnek commented on Dec 26, 2018

    @devsnek
    Member

    to be clear, the issue is that -0 evaluates to 0, it's not a bug with Object.is or console.log.

  3. bnoordhuis commented on Dec 27, 2018

    @bnoordhuis
    Member

    If it helps, this bug seems to persist after the function is optimized by TurboFan and therefore it's likely not an Ignition bug.

  4. ryzokuken commented on Dec 27, 2018

    @ryzokuken
    Contributor

    @TimothyGu this seems to be fixed on v11.5.0 as well:

    > $ node -v
    v11.5.0
    
    > $ node -e "console.log(Object.is(-0, 0))"
    false
  5. TimothyGu commented on Dec 27, 2018

    @TimothyGu
    MemberAuthor

    @ryzokuken You have to use the spread operator prior to the evaluation of -0 to make the bug surface.

  6. ryzokuken commented on Dec 27, 2018

    @ryzokuken
    Contributor

    @TimothyGu I'd already tried that:

    I see. Will try to investigate.

    > $ node 
    > [...[]]; console.log(Object.is(-0, 0));
    true
    undefined
  7. targos commented on Dec 28, 2018

    @targos
    Member

    This was fixed as a side-effect in v8/v8@1c48d52.

    That's a big change that we probably won't be able to backport.

  8. BridgeAR commented on Dec 29, 2018

    @BridgeAR
    Member

    @targos there do not seem to be a lot of conflicts in that commit when backprorting it to v11.

    @nodejs/v8 @psmarshall @bmeurer @hashseed would you be so kind and check what is required to backport the necessary commit?

  9. ryzokuken commented on Dec 29, 2018

    @ryzokuken
    Contributor

    @BridgeAR I think what @targos means is that since this isn't an isolated fix but a huge change, it won't be great idea to backport the whole commit. Had it been a smaller commit, I guess it would have been simpler.

  10. mikermcneil commented on May 2, 2019

    @mikermcneil
  11. BridgeAR commented on May 2, 2019

    @BridgeAR
  12. jasnell commented on Jun 26, 2020

    @jasnell
    Member

    This appears to be fixed in 10.x. Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions