Skip to content

assert.deepEqual loops forever with circular refs #6416

Description

@kuraga

Version: v4.4.3

Platform: Linux 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Code:

var assert = require('assert');

var b = {};
b.b = b;

var c = {};
c.b = c;

assert.deepEqual(b, c);

Expected: no exceptions.

Actual: RangeError: Maximum call stack size exceeded

See also:

Activity

  1. added
    assertIssues and PRs related to the assert subsystem.
    on Apr 27, 2016
  2. Trott commented on Apr 27, 2016

    @Trott
    Member

    Also affects deepStrictEqual().

  3. Trott commented on Apr 27, 2016

    @Trott
    Member

    Judging from the test, this is sort of by design. The original behavior was (apparently) to loop forever but now it throws an error instead.

    Should be fixable by keeping track of seen references. Not sure about the semver implications or if the Locked status of the API is an issue here or not. (I would consider this a bugfix myself, but others may disagree.)

  4. addaleax commented on Apr 27, 2016

    @addaleax
    Member

    @Trott I’ve looked a bit at the original issue linked above, and I think Ryan Dahl actually just forgot to pull in the patch which does what you suggest (nodejs/node-v0.x-archive#207 (comment)). Would say it’s a bugfix, too.

  5. Trott commented on Apr 27, 2016

    @Trott
    Member

    @addaleax Cool! I think I've got a fix almost ready to go, but if you're already working on it, I'm happy to drop it and go do something else.

  6. addaleax commented on Apr 27, 2016

    @addaleax
    Member

    @Trott No, sorry, didn’t mean to imply that I was coding anything right now – go ahead! 😄

  7. added a commit that references this issue on Apr 29, 2016
  8. added a commit that references this issue on May 4, 2016
  9. added a commit that references this issue on May 4, 2016
  10. added a commit that references this issue on Mar 31, 2017
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

    assertIssues and PRs related to the assert subsystem.confirmed-bugIssues and PRs for confirmed bugs.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions