You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bundle v8 that is compatible with bundled node #5851
v8 5.1 is not abi compatible with 5.0, which node 6 ships with. So, .modules=48 is incorrect. The way to fix this (I guess) would be to bundle a chrome version that comes with v8 that is compatible with the bundled node version.
See nodejs/nan#578 for answers from node, nan and v8 maintainers.
We usually use the same version of NODE_MODULE_VERSION with Node, so NAN can work with Electron without modifications. But there hasn't been a Node release with V8 5.1, and NAN has not been prepared for V8 5.1, it is then not safe for us to change NODE_MODULE_VERSION on our side.
I think the only thing we can do is to wait for Node to release a new version that uses V8 5.1.
What about reverting the v8 upgrade then? The problem with the current situation that I and others like @0x00A are facing is that some native modules that do work with node don't work with electron. And I agree with you that it doesn't make much sense to just go ahead and make it abi compatible with node still being behind.
It's not a big deal for me personally to just use electron 1.1.3, but from that point of view you could consider 1.2.0 to be "broken".
V8 5.1 is interesting in that it has only ABI breakages from 5.0 and it seems the Node team plans to apply an API compatibililty layer and merge V8 5.1 to Node 6.
What's the Electron plan to deal with this compatibility layer? NAN will most likely assume the layer is present as Node.js 6 will have it.
I feel as if some people on this thread are misusing ABI vs API breaking? Does everyone understand what an ABI-but-not-API breaking change is?
Like, this change breaks ABI but not API:
// In v1.0.0structFoo {
intbar;
charbaz[32];
};
// In v1.0.1structFoo {
charbaz[32];
intbar;
};
// In v1.0.0 bar is located at +0 from the beginning of the struct, in v1.0.1 this is at +0x20// Compiling this code from source works in both v1.0.0 and v1.0.1, it is not an API break// but it _is_ an ABI break.myFoo->bar=5;
Being a header-only library, NAN itself does not care about the ABI. As far as I know, there have been no significant API breakage in V8 5.1 either. Moreover, if NAN did not work, it would almost surely refuse to compile. Thus, NAN is almost surely compatible with V8 5.1. However, none of this applies when using prebuilt binaries of incompatible ABIs.
I am fairly certain that the problem here is ABI related and that the alleged rebuild does not properly build against the V8 version included in Electron, which for all I know could still be different from what is picked up by node-gyp operating on the bundled Node, which does not seem to use its bundled V8 under Electron. That the observed problem could not be reproduced on Windows, which does not support prebuild, points towards this.
There is no apparent reason why Nan::Null, which does nothing but forward to v8::Null would evaluate to true. It simply makes no sense, unless there is an ABI incompatibility. One possibility is that the attempts to rebuild the Node addon were built against the V8 version bundled in the bundled Node, which is not what Electron uses. It could also have been built against some other V8 version on the local file system. Who knows.
@kkoopa i recompiled with a patch that returns a string instead of that Nan::Null and I got the string as expected, but if i recompiled with the original source that returns the Nan::Null, it was returning again true instead. Idk if that helps.
I haven't yet verified whether my rebuild process was using the v8 version electron bundles with as a target, but the problem already starts with electron advertising it's shipping with ABI 48, but breaking the 48 abi due to the newer v8 version.
So, the ABI incompatiblity is obvious: the precompiled addon, correctly using the ABI for V8 5.0.71 calls v8::Null, which returns the field at index 7. When using the wrong V8 version, like Electron does, this ends up returning true instead of null, since the ABI changed and true is now located at index 7.
and at that point the expectation would be that the V8 version no longer dictates the NODE_MODULE_VERSION. It would be best to avoid tight coupling between V8 version and NODE_MODULE_VERSION.
At the very least, there’s going to be a transition time in which many addons don’t use the new native API. It might make more sense to just start another counter that can be incremented specifically when the new ABI/API changes?
I'm not sure if it solves this issue, but Node 8 has this new thing:
The N-API is an API for building native addons. It is independent of the underlying JavaScript runtime and is maintained as part of Node.js itself. The goal of this project is to keep the Application Binary Interface (ABI) stable across different Node.js versions.
The purpose of N-API is to separate add-ons from changes in the underlying JavaScript engine so that native add-ons can run with different Node.js versions without recompilation.
Activity
zcbenz commentedon Jun 6, 2016
We usually use the same version of
NODE_MODULE_VERSIONwith Node, so NAN can work with Electron without modifications. But there hasn't been a Node release with V8 5.1, and NAN has not been prepared for V8 5.1, it is then not safe for us to changeNODE_MODULE_VERSIONon our side.I think the only thing we can do is to wait for Node to release a new version that uses V8 5.1.
juliangruber commentedon Jun 6, 2016
What about reverting the v8 upgrade then? The problem with the current situation that I and others like @0x00A are facing is that some native modules that do work with node don't work with electron. And I agree with you that it doesn't make much sense to just go ahead and make it abi compatible with node still being behind.
It's not a big deal for me personally to just use electron 1.1.3, but from that point of view you could consider 1.2.0 to be "broken".
anaisbetts commentedon Jun 6, 2016
@juliangruber Did you rebuild them?
juliangruber commentedon Jun 6, 2016
@paulatbipsync yes, same results as with the prebuilt binaries
anaisbetts commentedon Jun 6, 2016
That's surprising, are you sure that your package isn't doing some kind of node-pre-gyp stuff where it's no-op'ing the build?
juliangruber commentedon Jun 6, 2016
To me that's actually not surprising because v8 5.1 isn't abi compatible with v8 5.0, see nodejs/nan#578 (comment)
juliangruber commentedon Jun 6, 2016
(And yes, I manually rebuilt and changed stuff around to verify it's not a problem with prebuilts)
anaisbetts commentedon Jun 6, 2016
Sure, but ABI doesn't matter if you're building from source
mgol commentedon Jun 7, 2016
V8 5.1 is interesting in that it has only ABI breakages from 5.0 and it seems the Node team plans to apply an API compatibililty layer and merge V8 5.1 to Node 6.
What's the Electron plan to deal with this compatibility layer? NAN will most likely assume the layer is present as Node.js 6 will have it.
anaisbetts commentedon Jun 7, 2016
I feel as if some people on this thread are misusing ABI vs API breaking? Does everyone understand what an ABI-but-not-API breaking change is?
Like, this change breaks ABI but not API:
kkoopa commentedon Jun 7, 2016
Being a header-only library, NAN itself does not care about the ABI. As far as I know, there have been no significant API breakage in V8 5.1 either. Moreover, if NAN did not work, it would almost surely refuse to compile. Thus, NAN is almost surely compatible with V8 5.1. However, none of this applies when using prebuilt binaries of incompatible ABIs.
I am fairly certain that the problem here is ABI related and that the alleged rebuild does not properly build against the V8 version included in Electron, which for all I know could still be different from what is picked up by node-gyp operating on the bundled Node, which does not seem to use its bundled V8 under Electron. That the observed problem could not be reproduced on Windows, which does not support prebuild, points towards this.
There is no apparent reason why
Nan::Null, which does nothing but forward tov8::Nullwould evaluate totrue. It simply makes no sense, unless there is an ABI incompatibility. One possibility is that the attempts to rebuild the Node addon were built against the V8 version bundled in the bundled Node, which is not what Electron uses. It could also have been built against some other V8 version on the local file system. Who knows.juliangruber commentedon Jun 7, 2016
@kkoopa i recompiled with a patch that returns a string instead of that
Nan::Nulland I got the string as expected, but if i recompiled with the original source that returns theNan::Null, it was returning againtrueinstead. Idk if that helps.I haven't yet verified whether my rebuild process was using the v8 version electron bundles with as a target, but the problem already starts with electron advertising it's shipping with ABI
48, but breaking the 48 abi due to the newer v8 version.kkoopa commentedon Jun 7, 2016
@juliangruber It does not bring any clarity to me.
The code in question hardly does anything.
So the most likely source of error is indeed an ABI incompatibility.
v8::Nullis defined herev8::Trueis defined herev8::Booleanis av8::Primitive, so the only significant difference between the two functions isI::kNullValueRootIndexvsI::kTrueValueRootIndex.In V8 5.0.71, we have
In V8 5.1.281, we have
So, the ABI incompatiblity is obvious: the precompiled addon, correctly using the ABI for V8 5.0.71 calls
v8::Null, which returns the field at index 7. When using the wrong V8 version, like Electron does, this ends up returningtrueinstead ofnull, since the ABI changed andtrueis now located at index 7.54 remaining items
src: update NODE_MODULE_VERSION to 51
addaleax commentedon Sep 30, 2016
At the very least, there’s going to be a transition time in which many addons don’t use the new native API. It might make more sense to just start another counter that can be incremented specifically when the new ABI/API changes?
Support future Node and Electron versions
zeke commentedon May 30, 2017
I'm not sure if it solves this issue, but Node 8 has this new thing:
https://nodejs.org/dist/latest-v8.x/docs/api/n-api.html
MylesBorins commentedon May 30, 2017
@zeke the N-API is definitely the thing that will eventually help solve this. in 8.x it is behind a flag as it is experimental.
It is also worth mentioning that it cannot be relied on until userland modules can build on top of
edit: I shouldn't say can... they technically can and it works. I meant more that it needs to reach a critical mass
codebytere commentedon Sep 23, 2018
At present (after v1.8) V8 versions should be exactly the same for both Node.js and Chromium!