GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — assert: fix infinite loop by BridgeAR · Pull Request #18611 · nodejs/node

Conversation

@BridgeAR

@BridgeAR BridgeAR commented Feb 7, 2018

Copy link
Copy Markdown
Member

If an object has a custom inspect function set and it returns the same output for different objects and those objects are compared using strict assert, an infinite loop is triggered because a loop is not well defined.

Commit 1 fixes that. The second commit changes the output for strict assert to deactivate custom inspect functions. Showing identical output would be very confusing for users. This fixes that edge case.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

assert

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
BridgeAR added 2 commits February 7, 2018 03:06
@BridgeAR
assert: fix infinite loop
155d932
In rare cirumstances it is possible to get a identical error diff.
In such a case the advances diffing runs into a infinite loop.
This fixes it by properly checking for extra entries.
@BridgeAR
assert: show proper differences
6d0eb21
Right now it is possible to get an AssertionError from input that has
the customInspect function set to always return the same value.

That way the error message is actually misleading because the output
is going to look the same. This fixes it by deactivating the custom
inspect function.
@nodejs-github-bot nodejs-github-bot added the errors Issues and PRs related to JavaScript errors originating in Node.js core. label Feb 7, 2018
@BridgeAR

BridgeAR commented Feb 7, 2018

Copy link
Copy Markdown
Member Author

CI https://ci.nodejs.org/job/node-test-pull-request/12983/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR

BridgeAR commented Feb 7, 2018

Copy link
Copy Markdown
Member Author

Since assert.strict has not yet landed in 9.x this is no breaking change.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR
BridgeAR requested review from addaleax, jasnell, joyeecheung and mcollina February 7, 2018 02:24
joyeecheung
joyeecheung approved these changes Feb 7, 2018
View reviewed changes
mcollina
mcollina approved these changes Feb 7, 2018
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@BridgeAR BridgeAR added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Feb 7, 2018
addaleax
addaleax approved these changes Feb 8, 2018
View reviewed changes

@addaleax addaleax left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d have a mild preference for using the custom inspect if and only if it differs, but this LGTM either way.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@BridgeAR

BridgeAR commented Feb 8, 2018

Copy link
Copy Markdown
Member Author

@addaleax I see your point that this might make sense. I am somewhat in-between your suggestion to only deactivate custom inspect if both show the same result and the other end: to everywhere deactivate custom inspect to make sure the errors will always show what is really in those objects.

The latter would for example prevent the possible case that someone tries to sneak in some malicious data with the premise that it will not be detected in errors because it uses a custom inspect function.

Right now I have a minor preference for the latter but I would like to hear others as well on it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR

BridgeAR commented Feb 10, 2018

Copy link
Copy Markdown
Member Author

@mcollina @joyeecheung any opinions on the comment?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented Feb 10, 2018

Copy link
Copy Markdown
Member

@BridgeAR I prefer keeping it disabled.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR
fixup
da63546
@BridgeAR

BridgeAR commented Feb 10, 2018

Copy link
Copy Markdown
Member Author

I added a commit to also disable it in another case that is not semver-major. I am going to open another PR that changes the behavior to always disable custom inspect as a default but that is of course semver-major.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR

BridgeAR commented Feb 10, 2018

Copy link
Copy Markdown
Member Author

CI https://ci.nodejs.org/job/node-test-commit-light/250/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mcollina
mcollina approved these changes Feb 12, 2018
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
BridgeAR added a commit to BridgeAR/node that referenced this pull request Feb 12, 2018
@BridgeAR
assert: fix infinite loop
656a5d0
In rare cirumstances it is possible to get a identical error diff.
In such a case the advances diffing runs into a infinite loop.
This fixes it by properly checking for extra entries.

PR-URL: nodejs#18611
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
BridgeAR added a commit to BridgeAR/node that referenced this pull request Feb 12, 2018
@BridgeAR
assert: show proper differences
0cdc877
Right now it is possible to get an AssertionError from input that has
the customInspect function set to always return the same value.

That way the error message is actually misleading because the output
is going to look the same. This fixes it by deactivating the custom
inspect function.

PR-URL: nodejs#18611
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@BridgeAR

BridgeAR commented Feb 12, 2018

Copy link
Copy Markdown
Member Author

Landed in 656a5d0, 0cdc877.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR BridgeAR closed this Feb 12, 2018
@MylesBorins MylesBorins added the backport-requested-v9.x label Feb 21, 2018
@MylesBorins

MylesBorins commented Feb 21, 2018

Copy link
Copy Markdown
Contributor

Should this be backported to v9.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BridgeAR added a commit to BridgeAR/node that referenced this pull request Mar 8, 2018
@BridgeAR
assert: fix infinite loop
ca8a591
In rare cirumstances it is possible to get a identical error diff.
In such a case the advances diffing runs into a infinite loop.
This fixes it by properly checking for extra entries.

PR-URL: nodejs#18611
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
BridgeAR added a commit to BridgeAR/node that referenced this pull request Mar 8, 2018
@BridgeAR
assert: show proper differences
254f888
Right now it is possible to get an AssertionError from input that has
the customInspect function set to always return the same value.

That way the error message is actually misleading because the output
is going to look the same. This fixes it by deactivating the custom
inspect function.

PR-URL: nodejs#18611
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@BridgeAR BridgeAR mentioned this pull request Mar 8, 2018
[9.x backport] assert & util PRs #19230
Closed
4 tasks done
@BridgeAR

BridgeAR commented Mar 8, 2018

Copy link
Copy Markdown
Member Author

Backport opened in #19230

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

MylesBorins pushed a commit that referenced this pull request Mar 15, 2018
@BridgeAR @MylesBorins
assert: fix infinite loop
4ca0fc4
In rare cirumstances it is possible to get a identical error diff.
In such a case the advances diffing runs into a infinite loop.
This fixes it by properly checking for extra entries.

Backport-PR-URL: #19230
PR-URL: #18611
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
MylesBorins pushed a commit that referenced this pull request Mar 15, 2018
@BridgeAR @MylesBorins
assert: show proper differences
61baaba
Right now it is possible to get an AssertionError from input that has
the customInspect function set to always return the same value.

That way the error message is actually misleading because the output
is going to look the same. This fixes it by deactivating the custom
inspect function.

Backport-PR-URL: #19230
PR-URL: #18611
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@targos targos mentioned this pull request Mar 18, 2018
v9.9.0 proposal #19428
Merged
MylesBorins pushed a commit that referenced this pull request Mar 20, 2018
@BridgeAR @MylesBorins
assert: fix infinite loop
9abbb6b
In rare cirumstances it is possible to get a identical error diff.
In such a case the advances diffing runs into a infinite loop.
This fixes it by properly checking for extra entries.

Backport-PR-URL: #19230
PR-URL: #18611
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
MylesBorins pushed a commit that referenced this pull request Mar 20, 2018
@BridgeAR @MylesBorins
assert: show proper differences
5e6b42e
Right now it is possible to get an AssertionError from input that has
the customInspect function set to always return the same value.

That way the error message is actually misleading because the output
is going to look the same. This fixes it by deactivating the custom
inspect function.

Backport-PR-URL: #19230
PR-URL: #18611
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
@BridgeAR @MayaLekova
assert: fix infinite loop
9b6817c
In rare cirumstances it is possible to get a identical error diff.
In such a case the advances diffing runs into a infinite loop.
This fixes it by properly checking for extra entries.

PR-URL: nodejs#18611
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
@BridgeAR @MayaLekova
assert: show proper differences
1729885
Right now it is possible to get an AssertionError from input that has
the customInspect function set to always return the same value.

That way the error message is actually misleading because the output
is going to look the same. This fixes it by deactivating the custom
inspect function.

PR-URL: nodejs#18611
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@MylesBorins MylesBorins added the backport-requested-v8.x label Jul 31, 2018
@MylesBorins

MylesBorins commented Jul 31, 2018

Copy link
Copy Markdown
Contributor

Requested backport to 8.x in #19230

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BridgeAR
BridgeAR deleted the fix-infinite-loop branch April 1, 2019 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina approved these changes
@addaleax addaleax addaleax approved these changes
@joyeecheung joyeecheung joyeecheung approved these changes
@jasnell jasnell Awaiting requested review from jasnell

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. errors Issues and PRs related to JavaScript errors originating in Node.js core.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@BridgeAR @mcollina @MylesBorins @addaleax @joyeecheung @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.