-
Notifications
You must be signed in to change notification settings - Fork 15.5k
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
Crash when node-ffi is required #2680
Comments
Did you follow the instructions mentioned here? |
I've followed them very carefully. Also the installAndStart script that I've included in the project is doing this - https://github.com/rosen-vladimirov/myElectronApp/blob/master/installAndStart.sh#L17 |
Your script probably didn't recompile all the native dependencies, I suggest using npm by setting the environment variables or just electron-rebuild instead. |
This means that electron-rebuild isn't working, you're using the iojs version. |
Thank you for your suggestions. I've added the script just for easier reproduction case. I've manually rebuild all modules and as I've said, I'm successfully rebuilding the same package and using it with iojs. @paulcbetts the error message about Dynamic Link Library is not the one that concerns me. I'm NOT receiving it after successfull rebuild. My electron app crashes directly after successfully rebuilding ALL native dependencies and requiring ffi. |
Hi, I've also tried the latest electron - 0.31.2, but it's still crashing 😢 |
This is a major blocking issue for us I'd really like to see this fixed too |
Currenly node-ffi doesn't support iojs v3 yet, the upgrade work is here: node-ffi/node-ffi#231. So you need to wait for the new release version of node-ffi or use electron v0.30.x as a workaround. |
Hi @hokein , |
Oh, I have missed it before. I can reproduce it too, it's probably a bug of Electron.
We do need this commit for embedded blink allocator in node's buffer. Because iojs reimplements node buffer in v0.3, and it starts to manage the memory of buffer, which conflicts with Blink's behavior. Instead of rebuilding and replace the node library for electron-prebuilt v0.31, I suggest you to build the whole electron, because there is extra build-related work on the node library(e.g. change the path of libnode on OS X). The following steps are:
|
A crash stack trace:
|
node-ffi stores pointer by passing it to Buffer (which is ArrayBuffer underlying), however in Chromium users are not allowed to create ArrayBuffer with their own pointers, and Electron works around it by copying the content pointed by the pointer to the ArrayBuffer allocated by Chromium. Unfortunately this resulted in node-ffi not getting the original pointer. I don't think it is fixable in Electron, but it should be very easy to fix it in node-ffi by using another way of storing pointer. |
Thank you for taking a look at this issue!!!
Is this change in latest Chromium versions, as the same code from ffi is working in older versions of Electron? |
It has always been required by Chromium, the problem is caused by Buffer being reimplemented as ArrayBuffer after io.js 3.0.0. |
Just FYI, Thanks in advance! |
@zcbenz, said that fixing the issue in |
@etiktin, here it is - node-ffi/node-ffi#236 Thank you all for your cooperation! |
Looks like the underlying problem was resolved in nodejs/node#2487, which was released in io.js v3.2.0. @zcbenz I guess the problem can be resolved by upgrading Electron's io.js to v3.2.0 or later? Alternatively patching with nodejs/node@07c0667. |
The crash in io.js is not the same one in Electron, but I think I have found a way to fix that in Electron without patching node-ffi. |
@zcbenz This is awesome - node-ffi is definitely a module we can't easily remove in the Slack app |
Hey guys, Thanks again! |
It is going to be included in v0.32.0. |
Bless u @zcbenz, and thanks @rosen-vladimirov for chasing down all of this useful history and debugging information, super helpful! |
i am still facing the issue . my electron application crashes eventually , don't have any clue why it is crashing , and their is no fix time of crashing, it crashes at any point at any time . |
Hi,
I'm trying to use node-ffi as dependency in the electron, but the require('ffi') leads to crash. Please note I'm using v2 branch of node-ffi, as it has support for iojs 3.x and this is the branch from which the new version should be released in npm very soon. The v2 branch can be required (after successful build of course) without any issues in iojs 2.x, iojs 3.x, node 0.12.x, but it fails in electron. I've noticed you are using a fork of node and there are some changes in it, so I've tried using older electron version - 0.29.1.The ffi module is successfully required with it, so I've checked the differences in your node's fork - the only one I see is this commit - could you share more details about it and could it cause the problem?
I've tried my app with electron 0.31.0 and 0.31.1, but without success.
You can find a sample application that reproduces the issue here. After cloning it, just run installAndStart script with target and architecture paramters, for example:
And the modules will be rebuild with correct headers. At the end the electron should start, but it just crashes.
I've tried rebuilding your node's fork without the latest commit, but I'm not sure how to produce dll from it in order to replace it in my electron's installation.
Could you check what's causing this crash? I would have contacted node-ffi's authors, but their version is working fine with real iojs, it looks like the latest commit in your iojs's fork is causing the issue.
Thanks in advance for your help!
The text was updated successfully, but these errors were encountered: