Unexpected SIGTRAP when running Electron

I have set up a minimal FHS environment in which I am trying to run an Electron app. However, every time I run electron, even without any parameters, it ends within one section with this:

+++ killed by SIGTRAP (core dumped) +++
Trace/breakpoint trap

Okay, the background. I just joined a new team that has a very large existing Rust and Electron application. I’m trying to get my machine set up, and while I can get everything to build, the app itself always fails because it is an electron app that throws this SIGTRAP. The core file contains a whole bunch of stack frames with no information because electron has no debugging symbols.

Only need two files to reproduce this, so here they are. First, the shell.nix:

let
    pkgs = import <pkgs-20.03> { };
in (pkgs.buildFHSUserEnv {
        name = "fhs";
        targetPkgs = pkgs: [
            pkgs.icu
            pkgs.file
            pkgs.git
            pkgs.gdb
            pkgs.bash
            pkgs.at-spi2-atk
            pkgs.at-spi2-core
            pkgs.atk
            pkgs.nodejs-12_x
            pkgs.glib
            pkgs.gtk3
            pkgs.xorg.libX11
            pkgs.xorg.libxcb
            pkgs.xorg.libXcomposite
            pkgs.xorg.libXcursor
            pkgs.xorg.libXdamage
            pkgs.xorg.libXext
            pkgs.xorg.libXfixes
            pkgs.xorg.libXi
            pkgs.xorg.libXrandr
            pkgs.xorg.libXrender
            pkgs.xorg.libXScrnSaver
            pkgs.xorg.libXtst 
            pkgs.nspr
            pkgs.nss
            pkgs.dbus
            pkgs.pango
            pkgs.expat
            pkgs.cairo
            pkgs.libdrm
            pkgs.mesa
            pkgs.gdk-pixbuf
            pkgs.alsaLib
            pkgs.cups
        ];

        runScript = "bash --init-file /etc/profile";
        profile = ''
            export C_INCLUDE_PATH=/usr/include:$C_INCLUDE_PATH
            export NODE_ENV=development
            
            if [ -e ~/.nixpkgs/shellhook.sh ]; then . ~/.nixpkgs/shellhook.sh; fi;
        '';
    }).env

Next, package.json:

{
  "name": "electron-env",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "electron": "9.0.2"
  }
}

To reproduce:

nix-shell
npm install
npx electron

And you should immediately see a core dump (if you have disabled systemd-coredump). file will identify it as having come from electron.

If anyone is willing to help, I would like to get this working. First, I don’t really want to do long-term development inside of a VM or reinstall my system with Ubuntu. Second… I might have accidentally converted my new team lead to NixOS, just by sharing my basic system files while he was putting NixOS into a VM.

I finally found the solution! The lack in the file above was for libudev!

First of all, I was able to find this solution by pulling both the electron zip file and the debug file from Release electron v9.0.2 · electron/electron · GitHub. It was important for me, after unzipping both, to move the .debug files into the same directory as my electron executable. I was then able to run electron, then apply gdb to the core dump.

ls -1

-rw-r--r--  1 savanni users     179981 Jan  1  1980 chrome_100_percent.pak
-rw-r--r--  1 savanni users     321151 Jan  1  1980 chrome_200_percent.pak
-rwxr-xr-x  1 savanni users    6322128 Jan  1  1980 chrome-sandbox
-rw-------  1 savanni users  213487616 Jun 26 21:40 core.11309
-rw-------  1 savanni users  203784192 Jun 26 21:45 core.12031
drwxr-xr-x  2 savanni users       4096 Jun 26 21:45 debug
-rwxr-xr-x  1 savanni users  129796744 Jan  1  1980 electron
-rwxr-xr-x  1 savanni users 1500482568 Jan  1  1980 electron.debug
-rw-r--r--  1 savanni users 1067459225 Jun 26 21:41 electron-v9.0.2-linux-x64-debug.zip
-rw-r--r--  1 savanni users   73660512 Jun 26 21:44 electron-v9.0.2-linux-x64.zip
-rw-r--r--  1 savanni users   10505952 Jan  1  1980 icudtl.dat
-rwxr-xr-x  1 savanni users     243992 Jan  1  1980 libEGL.so
-rwxr-xr-x  1 savanni users    1980936 Jan  1  1980 libEGL.so.debug
-rwxr-xr-x  1 savanni users    3103488 Jan  1  1980 libffmpeg.so
-rwxr-xr-x  1 savanni users    6316832 Jan  1  1980 libffmpeg.so.debug
-rwxr-xr-x  1 savanni users    8948960 Jan  1  1980 libGLESv2.so
-rwxr-xr-x  1 savanni users   16141232 Jan  1  1980 libGLESv2.so.debug
-rwxr-xr-x  1 savanni users    4488304 Jan  1  1980 libvk_swiftshader.so
-rwxr-xr-x  1 savanni users   43791632 Jan  1  1980 libvk_swiftshader.so.debug
-rwxr-xr-x  1 savanni users    8483376 Jan  1  1980 libvulkan.so
-rw-r--r--  1 savanni users       1060 Jan  1  1980 LICENSE
-rw-r--r--  1 savanni users    4710103 Jan  1  1980 LICENSES.chromium.html
drwxr-xr-x  2 savanni users       4096 Jun 26 21:45 locales
drwxr-xr-x 87 savanni users       4096 Jun 26 21:19 node_modules
-rw-r--r--  1 savanni users        299 Jun 26 21:19 package.json
-rw-r--r--  1 savanni users      27518 Jun 26 21:19 package-lock.json
drwxr-xr-x  2 savanni users       4096 Jun 26 21:45 resources
-rw-r--r--  1 savanni users    4791423 Jan  1  1980 resources.pak
-rw-r--r--  1 savanni users       1399 Jun 26 21:48 shell.nix
-rw-r--r--  1 savanni users      50592 Jan  1  1980 snapshot_blob.bin
drwxr-xr-x  2 savanni users       4096 Jun 26 21:45 swiftshader
-rw-r--r--  1 savanni users     170903 Jan  1  1980 v8_context_snapshot.bin
-rw-r--r--  1 savanni users          5 Jan  1  1980 version
-rw-r--r--  1 savanni users        107 Jan  1  1980 vk_swiftshader_icd.json

[fhs-shell-env] savanni@garnet:~/s/electron-env $ gdb electron core.14496

GNU gdb (GDB) 8.3.1
...
Reading symbols from electron...
Reading symbols from /home/savanni/src/electron-env/electron.debug...
...
warning: Unexpected size of section `.reg-xstate/14520' in core file.
#0  0x0000562334b7f493 in device::UdevLoader::Get()::$_0::operator()() const (this=<optimized out>)
    at ../../device/udev_linux/udev_loader.cc:38
38	../../device/udev_linux/udev_loader.cc: No such file or directory.
[Current thread is 1 (Thread 0x7fcf4e9bd700 (LWP 14520))]

So, as soon as I add libudev to the shell description above, I have everything I need to launch an electron app!

3 Likes

thank you @savannidgerinel ! this unblocked me! I was also missing the exact same package :smiley:

I was having the exact same problem, but libudev is not there anymore. I found out that it got merged into systemd now (see this post: [SOLVED] `libudev` replaced by `udev`? - #3 by jonringer)

I use a package that is based on Qt6, but it uses the Qt WebEngineCore.
It’s the same fundamental problem as it’s based on the Chromium browser.

I just added a

patchelf --add-needed libudev.so.1 $out/lib/libQt6WebEngineCore.so.6

and now it works.