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

Bug: application crashes when creating database, using Electron #59

Closed
NoxFly opened this issue Sep 7, 2023 · 11 comments
Closed

Bug: application crashes when creating database, using Electron #59

NoxFly opened this issue Sep 7, 2023 · 11 comments
Labels
solved ✔ This issue has been solved / answered third-party-issue This issue is related to a third-party library

Comments

@NoxFly
Copy link

NoxFly commented Sep 7, 2023

Hello,

Tech :
Node v18.13.0
npm v9.2.0
Electron v26.0
Javascript (not Typescript)
Linux Ubuntu 23.04.

From my researches on StackOverflow and Github, the versions I mentionned above are not relevant.
Minimal node version from my researches : 14
Minimal Electron version from my researches : 11
Javascript & Typescript.
All OS.

In my case, I needed to electron-rebuild -f -w better-sqlite3-multiple-ciphers because of my node version before using this library.

const sqlite = require('better-sqlite3-multiple-ciphers');

const db = sqlite('data.db');

This code is sufficient to cause a crash.
This occurs only when this is run through an Electron project.

Execute without Electron, all is working well.

The crash message :

/home/noxfly/codes/nodejs/electron/test/node_modules/electron/dist/electron exited with signal SIGSEGV

A lot of issues are opened in a lot of other library's repositories with the same behavior, always lambda library + Electron = SIGSEGV from Electron.

I don't know if it is to Electron's team to do something or the other library's team to find an alternative, and what us, end users, can do (because we would like to use both. Personnally I don't see other lib for database encryption and I don't know how to do myself, and of course keep electron for the main purpose of the application).

@NoxFly
Copy link
Author

NoxFly commented Sep 8, 2023

It seems that this issue is due to better-sqlite3 directly. Using another package (enmap) which also uses better-sqlite3, crashes when creating database, again with a SIGEGV.

@willemdjong
Copy link

willemdjong commented Sep 8, 2023

Same here, #57 after upgrading to electron v26.

@m4heshd
Copy link
Owner

m4heshd commented Sep 11, 2023

There are third-party issues being tracked regarding this bug.

WiseLibs/better-sqlite3#1042
prebuild/prebuild#309

Will keep this issue open till those are addressed.

@m4heshd m4heshd added third-party-issue This issue is related to a third-party library blocked-by-upstream 🛑 This issue is waiting for a fix on a depending library labels Sep 21, 2023
@jepiqueau
Copy link

I got the same issue with @capacitor-community/sqlite which use better-sqlite3-multiple-ciphers for the Electron part of the plugin capacitor-community/sqlite_issue#474. The plugin work fine with Electron 25.8.4 and better-sqlite3-multiple-ciphers 8.4.0 but when i upgrade Electron to 26.1.0 it failed:

called ipcMain.handle: CapacitorSQLite-open
/Volumes/Development_Lacie/Development/ionic7/angular-sqlite-app-starter/electron/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron exited with signal SIGSEGV
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               Electron [23496]
Path:                  /Volumes/VOLUME/*/Electron.app/Contents/MacOS/Electron
Identifier:            com.github.Electron
Version:               26.2.4 (26.2.4)
Code Type:             X86-64 (Native)
Parent Process:        node [23495]
Responsible:           Terminal [1462]
User ID:               501

Date/Time:             2023-10-01 11:50:01.7501 +0200
OS Version:            macOS 12.6.9 (21G726)
Report Version:        12
Bridge OS Version:     3.0 (14Y910)
Anonymous UUID:        F52BD279-4C53-B6B9-C38C-1439CFB5C8F0


Time Awake Since Boot: 19000 seconds

System Integrity Protection: enabled

Crashed Thread:        0  CrBrowserMain  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000014078
Exception Codes:       0x0000000000000001, 0x0000000000014078
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [23496]

VM Region Info: 0x14078 is not in any region.  Bytes before following region: 4516044680
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                      10d2ea000-10d2ec000    [    8K] r-x/r-x SM=COW  ...acOS/Electron

Thread 0 Crashed:: CrBrowserMain Dispatch queue: com.apple.main-thread
0   better_sqlite3.node           	       0x11425bd6c Statement::JS_new(v8::FunctionCallbackInfo<v8::Value> const&) + 188
1   Electron Framework            	       0x11fae5304 v8::internal::Accessors::MakeAccessor(v8::internal::Isolate*, v8::internal
```

my node version is v18.17.1

@willemdjong
Copy link

Any updates?

@NoxFly
Copy link
Author

NoxFly commented Oct 23, 2023

Any updates?

from this issue, Updating to Electron 27 solves the issue.
The issue is caused by internal dependency of Electron, (prebuild), and there's a discussion that partially explain that here.

It's not totally resolving the real issue, but at least there's a workaround.

@willemdjong
Copy link

Upgrade to v27 solved it.

@m4heshd
Copy link
Owner

m4heshd commented Oct 24, 2023

Closing this issue since this is as far as we're going to get to a fix until better-sqlite3 migrates to N-API.

@m4heshd m4heshd closed this as completed Oct 24, 2023
@m4heshd m4heshd added solved ✔ This issue has been solved / answered and removed blocked-by-upstream 🛑 This issue is waiting for a fix on a depending library labels Oct 24, 2023
@jepiqueau
Copy link

@m4heshd any idea on the plan date?

@m4heshd
Copy link
Owner

m4heshd commented Oct 24, 2023

@jepiqueau As far as I know, there are no plans in place yet. It's ultimately up to @JoshuaWise to decide since it's gonna be a massive refactor.

@jepiqueau
Copy link

@m4heshd @JoshuaWise OK thanks keep me aware when the decision will happen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solved ✔ This issue has been solved / answered third-party-issue This issue is related to a third-party library
Projects
None yet
Development

No branches or pull requests

4 participants