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

Getting an Electron crash, not sure how to further debug - help needed! #988

Open
rathboma opened this issue Apr 10, 2023 · 7 comments
Open

Comments

@rathboma
Copy link
Contributor

rathboma commented Apr 10, 2023

Hi folks,

I'm getting a full-app crash in my Electron app (Beekeeper Studio). It seems to be coming from better-sqlite3, but I don't get a printed stacktrace at all. I only get crash details when using crashpad/breakpad.

I don't really know how to figure out where better-sqlite3 is crashing, but it seems to be the cause of the crash?

image

This only happens 1/10 of the time.

Versions:

  • better-sqlite3 8.3.0
  • Electron 22.3.5
@mceachen
Copy link
Member

This isn't going to be the answer you're hoping for, but I found electron to be unstable when running native libraries from the main process. Current versions seem to be worse: I've had to pin to 21.4 as that seems to be the most recent version that works-ish.

For PhotoStructure, I have the main electron process spawn and monitor child processes (using ELECTRON_RUN_AS_NODE) to work around this. The spawned processes seem to be much happier to run native libraries.

See https://photostructure.com/server/photostructure-for-servers/#service-architecture for more details.

@rathboma
Copy link
Contributor Author

@mceachen Hey, thanks for the response. Yeah I've noticed the same thing, and have similar plans, but haven't had the time to re-architect the application yet. It's quite a large change. :-/.

@cbartondock
Copy link

I am also seeing a crash in electron crash in Electron 24.1.2. Happens relatively randomly when a database is re-opened. Yes I am closing them.

@rathboma
Copy link
Contributor Author

I downgraded to Electron 18 and that seems stable. Don't feel too bad about that as many big commercial apps are on 18 or earlier (eg vscode)

@indutny-signal
Copy link

indutny-signal commented Jul 20, 2023

FWIW, you might need to use patch like this to make it work: signalapp/better-sqlite3@1bf85ef . It isn't pretty, but the underlying issue is that V8 used by Chromium/Electron treats the first aligned pointer slot as holding a reference to their C++ heap that can be GCed. Thus if it finds something unexpected there - it might crash.

@rathboma
Copy link
Contributor Author

rathboma commented Feb 9, 2024

@indutny-signal I'm coming back to this issue thinking about how I upgrade my app to a new version of Electron.

Given that this is the version of V8 used by Electron -- is this problem present in all process types run by an electron app? Render, Main, and Utility?

I really know nothing about C++. Would this problem also be present in other native libraries (for me - Oracle's native libraries)

Thanks for any extra advice here.

@indutny-signal
Copy link

@rathboma I think the problem is only present in renderer process. If you use better-sqlite3 in main, it should be good to go without a patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants