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

build: make addon testing part of make test #6232

Merged
merged 1 commit into from
May 2, 2016

Conversation

bnoordhuis
Copy link
Member

@bnoordhuis bnoordhuis commented Apr 15, 2016

Checklist
  • tests and code linting passes
  • a test and/or benchmark is included
  • documentation is changed or added
  • the commit message follows commit guidelines
Affected core subsystem(s)

test

Description of change

build: make addon testing part of make test

Otherwise it's too easy to miss breaking changes to node.h and other
public headers until the CI catches them. vcbuild test tests addons
so there is precedence.

( test: is perhaps a better prefix but most commits to Makefile prefix with build. I follow slavishly.)

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

@bnoordhuis bnoordhuis added the test Issues and PRs related to the tests. label Apr 15, 2016
@MylesBorins
Copy link
Contributor

I'm very much in favor of this change. One thing worth mentioning is the flakyness of test-addons

When testing on osx I fairly often have to run the command twice in a row due to some issue I've never quite hunted down. Am I the only one experiencing this? @bnoordhuis I can try apply this patch to a couple different parts of the tree and see if I can repro the failures if you like

@bnoordhuis
Copy link
Member Author

I spent some time last year sorting out build dependencies and make test-addons has been pretty solid for me on Linux ever since. If you can tell me how to reproduce on OS X, I'll look into it.

@jasnell
Copy link
Member

jasnell commented Apr 15, 2016

I've seen the same flakiness on OS X but like @thealphanerd I haven't had a chance to track it down. I'll see if I can get some info later on today.

@mscdex mscdex added the c++ Issues and PRs that require attention from people who are familiar with C++. label Apr 15, 2016
@agnat
Copy link
Contributor

agnat commented Apr 20, 2016

I haven't had a chance to track it down.

All of this sounds terrible familiar, so I believe I have...

To clarify, on OS X once in a while we catch a "bad add-on build". That is plugging this "bad add-on" crashes reproducibly. It is not flaky in the sense that plugging may or may not work. Only rebuilding the add-on resolves the issue, right?

I tracked this down to a variant of what is sometimes called the C++ static initialization order fiasco. IIRC, it boils down to this: Both the initialization of the node::node_module struct and the NODE_C_CTOR() are run at init-time... under certain circumstances. Since the order of initialization is undefined those builds that run the ctor before initializing the struct fail.

Apparently this is no problem on ELF systems. The order is deterministic and correct. However, on Mach-O systems the order is non-deterministic and once in while we catch a bad build.

I fixed this in this commit while working on #2329, mostly as an afterthought. It popped up in the CI build.

So, why is this not a problem in the real world? This has to do with the circumstances mentioned above. Most add-ons use simple node_module structs that only contain compile-time constants. Such a struct is not initialized at init-time but at load-time. No order issues there. My guess is that one of the tests, being thorough, does something more interesting and thus triggers the issue. IIRC, one easy way to produce an add-on that shows the effect is to use a non-constant private field. Untested:

void Init() {}
void* GetPrivate() { return new int; }
NODE_MODULE_X(bad_add_on, Init, GetPrivate(), 0);

It still isn't easy to catch, though. I used an infinite rebuild-test-clean-loop...

@agnat
Copy link
Contributor

agnat commented Apr 22, 2016

I spent some time trying to reproduce this but it seems gone ...

So unless anyone else is able to reproduce, forget what I said. ;)

@bnoordhuis
Copy link
Member Author

@thealphanerd @jasnell Any luck? If not, I'd like to land this.

@jasnell
Copy link
Member

jasnell commented Apr 27, 2016

@bnoordhuis ... don't let me hold it up, I haven't had a chance to investigate further.

@MylesBorins
Copy link
Contributor

We may as well land this and if we start hitting the edge case often we can then start to fix it. I am pretty sure that we will, but cannot reliably reproduce

@bnoordhuis
Copy link
Member Author

@jbergstroem
Copy link
Member

LGTM

Otherwise it's too easy to miss breaking changes to node.h and other
public headers until the CI catches them.  `vcbuild test` tests addons
so there is precedence.

PR-URL: nodejs#6232
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
@bnoordhuis bnoordhuis closed this May 2, 2016
@bnoordhuis bnoordhuis deleted the test-addons-more branch May 2, 2016 05:39
@bnoordhuis bnoordhuis merged commit 628ae25 into nodejs:master May 2, 2016
Fishrock123 pushed a commit that referenced this pull request May 4, 2016
Otherwise it's too easy to miss breaking changes to node.h and other
public headers until the CI catches them.  `vcbuild test` tests addons
so there is precedence.

PR-URL: #6232
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
joelostrowski pushed a commit to joelostrowski/node that referenced this pull request May 4, 2016
Otherwise it's too easy to miss breaking changes to node.h and other
public headers until the CI catches them.  `vcbuild test` tests addons
so there is precedence.

PR-URL: nodejs#6232
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants