electron: [Bug]: Renderer Process crashes when native addon is used for any Electron >=9.0.0

Preflight Checklist

Electron Version

9.0.0

What operating system are you using?

Ubuntu

Operating System Version

Kubuntu 20.04

What arch are you using?

x64

Last Known Working Electron version

8.5.5

Expected Behavior

Renderer process should not crash when invoking function of native addon

Actual Behavior

We use native addons to bring high speed simulation functionality to our Electron app.

However, when we upgrade from currently 8.X.X to any Version >=9.0.0, our native addon does not work anymore. Not at all. When we try to call any native function on >=9.0.0, the renderer process crashes.

I have prepared somewhat minimum repros, which you will see linked below

For performance purposes, we need to load the addon in the renderer process

Repro guide:

git clone git@github.com:robinchrist/electron-native-addon-89-corelib.git
git clone git@github.com:robinchrist/electron-native-addon-89-electron.git

cd electron-native-addon-89-corelib
git checkout electron-8.5.5
npm ci
npm run testpackage

cd ../electron-native-addon-89-electron
npm ci
npm start

in Devtools

addon = window.require('corelib-test')
addon.NATIVE.calculateSync(1.0, 2.0, 3.0)

-> WORKS Output is (9) [0, 1, 2, 3, 4, 5, 6, 7, 8]

Close node / electron

Now recompile addon for Electron 9.0.0 and upgrade electron part to 9.0.0 too


cd ../electron-native-addon-89-corelib
git checkout electron-9.0
npm run testpackage

cd ../electron-native-addon-89-electron
git checkout electron-9.0
npm ci
npm start

in Devtools

addon = window.require('corelib-test')
addon.NATIVE.calculateSync(1.0, 2.0, 3.0)

-> SEGFAULT / Renderer Crash

Note that this happens with EVERY Version >= 9.0.0 If you want to test, you can just replace “9.0.0” with any other version. But keep in mind to also replace it in the addon, recompile the addon and install the recompiled version (otherwise you will get an error that the addon could not be found due to ABI mismatch)

I have tried to debug it with lldb, but I’m not getting any useful results without Electron debug symbols… I will build a debug version of electron tomorrow and see whether I can find anything wrong

The repro ONLY works for Linux! Tested with Kubuntu 20.04, node v14.18.1, npm 8.1.0, compiler Ubuntu clang version 12.0.1-++20211011094644+fed41342a82f-1~exp1~20211011215105.3

Testcase Gist URL

No response

Additional Information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (7 by maintainers)

Most upvoted comments

Yes, I will prepare a PR within the next days!

@miniak yep, that was it.

I have filed a bug at cmake-ts, the fork of cmake-js I am using.

Perhaps this should be highlighted in the documentation about native addons, in case anyone tries to build their own build system?