Skip to content

Conversation

@mykmelez
Copy link
Contributor

Node fails to compile when configured --without-v8-platform because of two issues with the implementation in src/node.cc when !NODE_USE_V8_PLATFORM. This branch fixes those two issues.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes (Note: make -j4 test passes with these changes when I build with the default configure options. It fails when I build --without-v8-platform, but since previously it didn't even compile with that option, these changes are still an improvement.)
  • commit message follows commit guidelines
Affected core subsystem(s)

The affected core subsystem appears to be "src", or possibly "build." The only file that is changed is src/node.cc.

v8_platform.platform_ is referenced by node::Start without regard to the value of NODE_USE_V8_PLATFORM, so it should be declared unconditionally, otherwise Node fails to compile when !NODE_USE_V8_PLATFORM.
The call signature of v8_platform.StartInspector needs to be the same whether or not NODE_USE_V8_PLATFORM, otherwise Node will fail to compile if HAVE_INSPECTOR and !NODE_USE_V8_PLATFORM.
@nodejs-github-botnodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Jan 31, 2017
@mykmelezmykmelez changed the title fix building --without-v8-platformsrc: fix building --without-v8-platformJan 31, 2017
@bnoordhuis
Copy link
Member

Second commit LGTM but @matthewloring should review the first one because I don't think passing a nullptr to node::tracing::Agent::Start() is allowed.

@matthewloring
Copy link

That is correct. I think we will need to follow the same pattern used by the inspector agent here which starts the agent if NODE_USE_V8_PLATFORM is set and throwing an exception otherwise. We could then call the function in place of the call here.

node::tracing::Agent::Start can't accept a nullptr argument to its platform parameter, so don't call it when Node is compiled with NODE_USE_V8_PLATFORM=0.
@mykmelezmykmelezforce-pushed the fix-without-v8-platform branch from 907f1f2 to 0e9c0cbCompareFebruary 1, 2017 22:31
@mykmelez
Copy link
ContributorAuthor

@bnoordhuis, @matthewloring: We can't throw an exception, because node::Start() calls node::tracing::Agent::Start() before the Environment gets defined, so Environment::ThrowError() is not yet available. However, we can still refactor the call to node::tracing::Agent::Start() into v8_platform and avoid calling it unless NODE_USE_V8_PLATFORM=1. I've done that in 0e9c0cb.

Note: I opted to warn rather than exiting if NODE_USE_V8_PLATFORM=0 and --trace-events-enabled, because exiting would complicate node::Start(), which would have to check the return value of v8_platform.StartTracingAgent() and conditionally exit early. However, I can change it to exit early if you think it's important for the process to die in that case.

Note that I had to move the call to node::tracing::Agent::Stop() into v8_platform as well in order to ensure it doesn't get called if NODE_USE_V8_PLATFORM=0.

@matthewloring
Copy link

matthewloring commented Feb 1, 2017

I don't have a preference between an error and a warning. The approach looks good on my end.

@mykmelez
Copy link
ContributorAuthor

Note that I had to move the call to node::tracing::Agent::Stop() into v8_platform as well in order to ensure it doesn't get called if NODE_USE_V8_PLATFORM=0.

Erm, to be precise: I didn't have to move that call, since Agent::Stop() returns early if !IsStarted(). But if v8_platform is conditionally calling Agent::Start(), then it seems intuitive for it to conditionally call Agent::Stop() as well.

src/node.cc Outdated
#endif// HAVE_INSPECTOR

voidStartTracingAgent(){
tracing_agent = newtracing::Agent();
Copy link
Member

Choose a reason for hiding this comment

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

Can you make this a property of v8_platform while you're here (and call it tracing_agent_)? Maybe also insert a CHECK(tracing_agent_ == nullptr) to detect double calls.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Yes, I've done both of these things in b93584b. In the process, I also spotted another direct call to tracing_agent->Stop() and replaced it with a call to v8_platform.StopTracingAgent().

Move tracing_agent global into the v8_platform struct, renaming it to tracing_agent_; CHECK(tracing_agent_ == nullptr) in StartTracingAgent() to detect double calls; and relace another tracing_agent->Stop() call with a call to StopTracingAgent().
Copy link
Member

@bnoordhuisbnoordhuis left a comment

Choose a reason for hiding this comment

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

Copy link
Member

@mhdawsonmhdawson left a comment

Choose a reason for hiding this comment

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

LGTM

jasnell pushed a commit that referenced this pull request Feb 3, 2017
* declare v8_platform.platform_ unconditionally v8_platform.platform_ is referenced by node::Start without regard to the value of NODE_USE_V8_PLATFORM, so it should be declared unconditionally, otherwise Node fails to compile when !NODE_USE_V8_PLATFORM. * update v8_platform.StartInspector signature The call signature of v8_platform.StartInspector needs to be the same whether or not NODE_USE_V8_PLATFORM, otherwise Node will fail to compile if HAVE_INSPECTOR and !NODE_USE_V8_PLATFORM. * don't call tracing_agent->Start w/nullptr node::tracing::Agent::Start can't accept a nullptr argument to its platform parameter, so don't call it when Node is compiled with NODE_USE_V8_PLATFORM=0. * refactor tracing_agent into v8_platform Move tracing_agent global into the v8_platform struct, renaming it to tracing_agent_; CHECK(tracing_agent_ == nullptr) in StartTracingAgent() to detect double calls; and relace another tracing_agent->Stop() call with a call to StopTracingAgent(). PR-URL: #11088 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
@jasnell
Copy link
Member

Landed in 046f66a

@jasnelljasnell closed this Feb 3, 2017
@italoacasas
Copy link

This commits depends on a semver-major, do we have a plan to backport this to v7.-x?

@mykmelezmykmelez deleted the fix-without-v8-platform branch February 4, 2017 01:38
@mykmelez
Copy link
ContributorAuthor

This commits depends on a semver-major, do we have a plan to backport this to v7.-x?

The issue doesn't exist in v7.x, so there's no need to backport anything.

@mykmelez
Copy link
ContributorAuthor

The issue doesn't exist in v7.x, so there's no need to backport anything.

Erm, correction: one of the issues addressed in this PR does exist in v7.x, so I've opened #11157 to backport its fix.

krydos pushed a commit to krydos/node that referenced this pull request Feb 25, 2017
* declare v8_platform.platform_ unconditionally v8_platform.platform_ is referenced by node::Start without regard to the value of NODE_USE_V8_PLATFORM, so it should be declared unconditionally, otherwise Node fails to compile when !NODE_USE_V8_PLATFORM. * update v8_platform.StartInspector signature The call signature of v8_platform.StartInspector needs to be the same whether or not NODE_USE_V8_PLATFORM, otherwise Node will fail to compile if HAVE_INSPECTOR and !NODE_USE_V8_PLATFORM. * don't call tracing_agent->Start w/nullptr node::tracing::Agent::Start can't accept a nullptr argument to its platform parameter, so don't call it when Node is compiled with NODE_USE_V8_PLATFORM=0. * refactor tracing_agent into v8_platform Move tracing_agent global into the v8_platform struct, renaming it to tracing_agent_; CHECK(tracing_agent_ == nullptr) in StartTracingAgent() to detect double calls; and relace another tracing_agent->Stop() call with a call to StopTracingAgent(). PR-URL: nodejs#11088 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
@jasnelljasnell mentioned this pull request Apr 4, 2017
@gibfahngibfahn mentioned this pull request Jun 15, 2017
3 tasks
@gibfahn
Copy link
Member

Marking dont-land-on-v6.x due to #11157 (comment), if this is incorrect let me know.

Sign up for freeto 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++.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@mykmelez@bnoordhuis@matthewloring@jasnell@italoacasas@gibfahn@mhdawson@nodejs-github-bot