Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function has non-object prototype 'null' in instanceof check, when I use node but it is fine in Browser #35730

Closed
jackIsZlg opened this issue Oct 21, 2020 · 10 comments
Assignees
Labels
confirmed-bug Issues with confirmed bugs. util Issues and PRs related to the built-in util module.

Comments

@jackIsZlg
Copy link

Looks like a Node.js bug. Logging an object should never crash. The same works in the browser:

function X () {}
X.prototype = null;
x = {};
x.constructor = X;
console.log(x);

Node.js:

Uncaught TypeError: Function has non-object prototype 'null' in instanceof check
    at Function.[Symbol.hasInstance] (<anonymous>)
    at getConstructorName (internal/util/inspect.js:535:13)
    at formatRaw (internal/util/inspect.js:803:23)
    at formatValue (internal/util/inspect.js:793:10)
    at inspect (internal/util/inspect.js:326:10)
    at formatWithOptionsInternal (internal/util/inspect.js:1994:40)
    at formatWithOptions (internal/util/inspect.js:1878:10)
    at Object.value (internal/console/constructor.js:306:14)
    at Object.log (internal/console/constructor.js:341:61)

Browser:

{constructor: ƒ}

node Verison: v14.14.0

@targos
Copy link
Member

targos commented Oct 21, 2020

@nodejs/util

@targos targos added the util Issues and PRs related to the built-in util module. label Oct 21, 2020
@BridgeAR BridgeAR added the confirmed-bug Issues with confirmed bugs. label Oct 21, 2020
@BridgeAR BridgeAR self-assigned this Oct 21, 2020
baylesa-dev pushed a commit to baylesa-dev/node that referenced this issue Oct 22, 2020
Remove a useless check on Object descriptor. It seems like js browsers engine dont do this check.

Fixes: nodejs#35730
baylesa-dev pushed a commit to baylesa-dev/node that referenced this issue Oct 22, 2020
Remove a useless check on Object descriptor. It seems like js browsers engine dont do this check.

Fixes: nodejs#35730
@samal-rasmussen
Copy link

Are there any version of node that are not affected by this bug?

@7kms
Copy link

7kms commented Nov 10, 2020

v14.15.0 is also fail

@kaizhu256
Copy link
Contributor

kaizhu256 commented Nov 10, 2020

looks like v14-regression. v12 (both linux and win32-platform) works fine

#!/bin/sh
node -e '
console.log(process.platform, process.versions);
function X () {}
X.prototype = null;
x = {};
x.constructor = X;
console.log(x);
'

# stdout
# win32 {
#   node: '12.16.0',
#   v8: '7.8.279.23-node.31',
#   uv: '1.34.0',
#   zlib: '1.2.11',
#   brotli: '1.0.7',
#   ares: '1.15.0',
#   modules: '72',
#   nghttp2: '1.40.0',
#   napi: '5',
#   llhttp: '2.0.4',
#   http_parser: '2.9.3',
#   openssl: '1.1.1d',
#   cldr: '35.1',
#   icu: '64.2',
#   tz: '2019c',
#   unicode: '12.1'
# }
# X { constructor: [Function: X] }

@Trystan-SA
Copy link

(On Windows 10 - MSI x64 installer)
Node 14.0.0 Work
Node 14.2.0 Work
Node 14.3.0 Work
Node 14.4.0 Work
Node 14.5.0 Fail
Node 14.15.1 Fail
Node 15.2.1 Fail

So something between 14.4.0 and 14.5.0 probably created this bug.

@ExE-Boss
Copy link
Contributor

@Trystan-SA
The PR that caused the regression is #33449.

BridgeAR added a commit to BridgeAR/node that referenced this issue Nov 19, 2020
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Fixes: nodejs#35730
@jasonwilliams
Copy link

jasonwilliams commented Dec 10, 2020

This fails for me on v15.0.1

I get

TypeError: Function has non-object prototype 'null' in instanceof check
    at Function.[Symbol.hasInstance] (<anonymous>)
    at getConstructorName (node:internal/util/inspect:545:13)
    at formatRaw (node:internal/util/inspect:813:23)
    at formatValue (node:internal/util/inspect:803:10)
    at formatProperty (node:internal/util/inspect:1689:11)
    at formatRaw (node:internal/util/inspect:1017:9)
    at formatValue (node:internal/util/inspect:803:10)
    at formatProperty (node:internal/util/inspect:1689:11)
    at formatRaw (node:internal/util/inspect:1017:9)
    at formatValue (node:internal/util/inspect:803:10)
    at formatProperty (node:internal/util/inspect:1689:11)
    at formatArray (node:internal/util/inspect:1519:17)
    at formatRaw (node:internal/util/inspect:1014:14)
    at formatValue (node:internal/util/inspect:803:10)
    at formatProperty (node:internal/util/inspect:1689:11)
    at formatRaw (node:internal/util/inspect:1017:9)
    at formatValue (node:internal/util/inspect:803:10)
    at formatProperty (node:internal/util/inspect:1689:11)
    at formatRaw (node:internal/util/inspect:1017:9)
    at formatValue (node:internal/util/inspect:803:10)
    at Object.inspect (node:internal/util/inspect:336:10)

from hitting https://github.com/karma-runner/karma/blob/master/lib/server.js#L66

nodejs-github-bot pushed a commit that referenced this issue Dec 12, 2020
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Fixes: #35730

PR-URL: #36178
Fixes: #36151
Refs: #35754
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this issue Dec 21, 2020
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Fixes: #36151

PR-URL: #36178
Fixes: #35730
Refs: #35754
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this issue Dec 21, 2020
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Fixes: #35730

PR-URL: #36178
Fixes: #36151
Refs: #35754
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 27, 2021
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Fixes: nodejs#36151

PR-URL: nodejs#36178
Fixes: nodejs#35730
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 27, 2021
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Fixes: nodejs#35730

PR-URL: nodejs#36178
Fixes: nodejs#36151
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 27, 2021
Backport-PR-URL: nodejs#37100

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Fixes: nodejs#36151

PR-URL: nodejs#36178
Fixes: nodejs#35730
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 27, 2021
Backport-PR-URL: nodejs#37100

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Fixes: nodejs#35730

PR-URL: nodejs#36178
Fixes: nodejs#36151
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 29, 2021
Backport-PR-URL: nodejs#37100

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Fixes: nodejs#36151

PR-URL: nodejs#36178
Fixes: nodejs#35730
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 29, 2021
Backport-PR-URL: nodejs#37100

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Fixes: nodejs#35730

PR-URL: nodejs#36178
Fixes: nodejs#36151
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 29, 2021
Backport-PR-URL: nodejs#37100

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Fixes: nodejs#36151

PR-URL: nodejs#36178
Fixes: nodejs#35730
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 29, 2021
Backport-PR-URL: nodejs#37100

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Fixes: nodejs#35730

PR-URL: nodejs#36178
Fixes: nodejs#36151
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 29, 2021
Backport-PR-URL: nodejs#37100

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Fixes: nodejs#36151

PR-URL: nodejs#36178
Fixes: nodejs#35730
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Pezmc pushed a commit to Pezmc/node that referenced this issue Jan 29, 2021
Backport-PR-URL: nodejs#37100

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Fixes: nodejs#35730

PR-URL: nodejs#36178
Fixes: nodejs#36151
Refs: nodejs#35754
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
BethGriggs pushed a commit that referenced this issue Feb 5, 2021
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Backport-PR-URL: #37100
PR-URL: #36178
Fixes: #35730
Fixes: #36151
Refs: #35754
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
BethGriggs pushed a commit that referenced this issue Feb 5, 2021
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Backport-PR-URL: #37100
PR-URL: #36178
Fixes: #35730
Fixes: #36151
Refs: #35754
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
BethGriggs pushed a commit that referenced this issue Feb 5, 2021
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Backport-PR-URL: #37100
PR-URL: #36178
Fixes: #35730
Fixes: #36151
Refs: #35754
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@marxangels
Copy link

v14.17.0 OK

@npenin
Copy link

npenin commented Jun 25, 2022

I found another way to reproduce this one (on node v16.15.1):

var x={}
console.log(x instanceof Proxy)

Can we reopen the bug ?

@nodejs nodejs deleted a comment from jackIsZlg Jun 25, 2022
@bnoordhuis
Copy link
Member

@npenin can you open a new issue? It's probably not the same bug.

(for the audit log: removed an OoO auto-reply while I was here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. util Issues and PRs related to the built-in util module.
Projects
None yet