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

n-api: investigate breakage #12279

Closed
wants to merge 1 commit into from
Closed

Conversation

refack
Copy link
Contributor

@refack refack commented Apr 8, 2017

Check to see If this will turn the CI green, that will mean that #12240 breaks on windows
Now the suspect is lines L2186-L2187 in node_api.cc 8fbace1/#12246.

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

n-api,test

@nodejs-github-bot nodejs-github-bot added addons Issues and PRs related to native addons. test Issues and PRs related to the tests. labels Apr 8, 2017
@TimothyGu
Copy link
Member

The failed test 332 is:

not ok 332 addons-napi/test_instanceof/test
  ---
  duration_ms: 0.231
  severity: fail
  stack: |-
    
    assert.js:82
      throw new assert.AssertionError({
      ^
    AssertionError: true === undefined
        at assertTrue (c:\workspace\node-test-binary-windows\RUN_SUBSET\3\VS_VERSION\vcbt2015\label\win10\test\addons-napi\test_instanceof\test.js:16:17)
        at eval (eval at testFile (c:\workspace\node-test-binary-windows\RUN_SUBSET\3\VS_VERSION\vcbt2015\label\win10\test\addons-napi\test_instanceof\test.js:38:3), <anonymous>:29:1)
        at testFile (c:\workspace\node-test-binary-windows\RUN_SUBSET\3\VS_VERSION\vcbt2015\label\win10\test\addons-napi\test_instanceof\test.js:38:3)
        at Object.<anonymous> (c:\workspace\node-test-binary-windows\RUN_SUBSET\3\VS_VERSION\vcbt2015\label\win10\test\addons-napi\test_instanceof\test.js:42:1)
        at Module._compile (module.js:607:30)
        at Object.Module._extensions..js (module.js:618:10)
        at Module.load (module.js:516:32)
        at tryModuleLoad (module.js:466:12)
        at Function.Module._load (module.js:458:3)
        at Module.runMain (module.js:643:10)

which is unrelated to test/addons/make-callback-recurse/test.js. It's more likely that this test failure comes from 8fbace1/#12246.

@TimothyGu TimothyGu closed this Apr 8, 2017
@TimothyGu TimothyGu reopened this Apr 8, 2017
@TimothyGu
Copy link
Member

(closed by accident)

@refack
Copy link
Contributor Author

refack commented Apr 8, 2017

CI: https://ci.nodejs.org/job/node-test-pull-request/7275/
🤷
Meanwhile I'm building locally so I can repro & debug

@mscdex
Copy link
Contributor

mscdex commented Apr 8, 2017

It does seem to be that commit/PR. Here is another run on current master: https://ci.nodejs.org/job/node-test-binary-windows/7558/

I wonder if something got changed after CI was run in that PR.

@gabrielschulhof
Copy link
Contributor

I'd like to see which combination of value/constructor causes the napi_instanceof() assertion to fail. To that end, I have created https://github.com/gabrielschulhof/node/tree/fix-windows-build which introduces only https://github.com/nodejs/node/compare/master...gabrielschulhof:fix-windows-build?expand=1 just to see, but I can't start a CI on that. @refack can you start a Windows-only CI on that?

@gabrielschulhof
Copy link
Contributor

Yaaaaay! It seems I can reproduce the problem locally - albeit on a super-slow Windows VM 🎉

@gabrielschulhof
Copy link
Contributor

Sure enough, if I comment out the line that actually caches Symbol.hasInstance, the test passes 😕

@refack refack changed the title n-api: investigate if breakage is from #12440 n-api: investigate breakage Apr 8, 2017
@gabrielschulhof
Copy link
Contributor

Added a bunch of printfs, and I'm StrictEqualsing a freshly retrieved Symbol.hasInstance with the contents of the persistent. Unfortunately my round trip time is like 44 minutes :(

@refack
Copy link
Contributor Author

refack commented Apr 8, 2017

Unfortunately my round trip time is like 44 minutes :(

I'm able to repro on my machine. send me your current diff, I believe my round trip will be much shorter.

@gabrielschulhof
Copy link
Contributor

@gabrielschulhof
Copy link
Contributor

@refack Thanks!

@gabrielschulhof
Copy link
Contributor

Wow! It looks like the persistent works if I keep retrieving the symbol, even if I don't use the freshly retrieved value. Now I'm confused.

@gabrielschulhof
Copy link
Contributor

gabrielschulhof commented Apr 8, 2017

My latest suspicion:

https://github.com/nodejs/node/blob/master/src/node_api.cc#L2188
https://github.com/nodejs/node/blob/master/src/node_api.cc#L2195

In these two places we do if (status != napi_ok) return status; even though we didn't previously make a N-API call. In fact, in the second place we're checking status uninitialized.

@gabrielschulhof
Copy link
Contributor

... and the second place is that runs most often, because we will have the symbol cached after the first time every time. Running my slow turnaround now.

@gabrielschulhof
Copy link
Contributor

I'm surprised that using an uninitialized variable in an if-statement hasn't generated a warning.

@gabrielschulhof
Copy link
Contributor

Would a macro like this:

#define NAPI_CALL(theCall)                \
  do {                                    \
    napi_status status = theCall;         \
    if (status != napi_ok) return status; \
  } while(0)

get optimized down to what we have now without a perf hit? If so, I will replace all this status retrieval and checking.

gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this pull request Apr 8, 2017
Initialize status to napi_generic_failure and only check it after
having made an actual N-API call.

This fixes up 8fbace1.
@gabrielschulhof
Copy link
Contributor

#12283 should fix the problem. @refack could you please run a CI on it?

@refack
Copy link
Contributor Author

refack commented Apr 8, 2017

#12283 should fix the problem. @refack could you please run a CI on it?

Ha 😄 I got to the same conclusion (8db5a0b)

@refack
Copy link
Contributor Author

refack commented Apr 8, 2017

Made obsolete by #12283

@refack refack closed this Apr 8, 2017
refack pushed a commit that referenced this pull request Apr 8, 2017
Initialize status to napi_generic_failure and only check it after
having made an actual N-API call.

This fixes up 8fbace1.

PR-URL: #12283
Ref: #12279
Reviewed-By: Refael Ackermann <[email protected]>
@refack refack deleted the refack-patch-12440 branch April 8, 2017 22:45
@refack refack added the regression Issues related to regressions. label Apr 17, 2017
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this pull request Apr 10, 2018
Initialize status to napi_generic_failure and only check it after
having made an actual N-API call.

This fixes up 8fbace1.

PR-URL: nodejs#12283
Ref: nodejs#12279
Reviewed-By: Refael Ackermann <[email protected]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
Initialize status to napi_generic_failure and only check it after
having made an actual N-API call.

This fixes up 8fbace1.

Backport-PR-URL: #19447
PR-URL: #12283
Ref: #12279
Reviewed-By: Refael Ackermann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addons Issues and PRs related to native addons. regression Issues related to regressions. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants