App crashes even in devmode. How do I debug it?

We have an Electron app that we are looking to bring to snap. We package our snap with the latest electron-builder. I set the app to confinement: devmode and install it with snap install my-app_0.0.1_amd64.snap --devmode, yet it still just seems to crash when trying to launch it. On Ubuntu 16.04, I see it open in the launcher bar and then flash blue a few times, and then it goes away.

All debugging docs I’ve read just mention to run in --devmode to try and figure issues like this out, but our app wont even run this way. What can I do?

If interested, the latest snaps (in strict mode) for the app can be found here.


Update 1:

I also tried using snappy-debug and I just get the following 3 log entries before the app closes. Doesn’t look like any errors to me?

$ sudo /snap/bin/snappy-debug.security scanlog myapp
= AppArmor =
Time: Feb 23 17:35:36
Log: apparmor="ALLOWED" operation="dbus_method_call"  bus="session" path="/org/gnome/GConf/Database/0" interface="org.gnome.GConf.Database" member="AddNotify" mask="send" name="org.gnome.GConf" pid=14323 label="snap.myapp.myapp" peer_pid=9443 peer_label="unconfined"
DBus access

= AppArmor =
Time: Feb 23 17:35:36
Log: apparmor="ALLOWED" operation="dbus_method_call"  bus="session" path="/org/gnome/GConf/Database/0" interface="org.gnome.GConf.Database" member="AllEntries" mask="send" name="org.gnome.GConf" pid=14323 label="snap.myapp.myapp" peer_pid=9443 peer_label="unconfined"
DBus access

= AppArmor =
Time: Feb 23 17:35:36
Log: apparmor="ALLOWED" operation="dbus_method_call"  bus="session" path="/org/gnome/GConf/Database/0" interface="org.gnome.GConf.Database" member="LookupExtended" mask="send" name="org.gnome.GConf" pid=14323 label="snap.myapp.myapp" peer_pid=9443 peer_label="unconfined"
DBus access

Update 2:

If I go to /snap/my-app/current/ and execute my-app, the Electron app launches correctly and I can see the app run as expected, though this doesn’t seem to be running in the snap sandbox.

We’ve recently introduced first class support for strace, so you can just run snap run --strace <snap app> and get it under strace. I’ve also heard from good sources :slight_smile: that @mvo wants to get gdb working under the same scheme, so soon that’ll be doable too.

Something else you can do today with applications, which you might already be aware, is running a shell inside the confined space via snap run --shell <snap app>. This will allow you to more easily introspect and play with the system in the same way the application is playing.

Finally, there’s a chance @jdstrand will look into this and know exactly what to do for sorting the problem. That happens surprisingly often. :slight_smile:

If you are running a core from beta,candidate,edge you can run:

snap run --gdb test-snapd-tools.echo foo

Note that this is very new so please let us know how it works for you.

1 Like

@niemeyer I tried snap run --strace my-app but that resulted in a massive amount of traces that I haven’t been able to disseminate anything useful from yet.


@mvo I tried:

$ sudo snap refresh snapcraft --beta
$ snap run --gdb test-snapd-tools.echo my-app

and I get

error: unknown flag 'gdb'

Is snapcraft not what I need to move to beta for this? How do I get to the snap beta channel? Sorry, a little new to snap here.

I think @mvo implied refreshing the core to beta, so something like

$ snap refresh core --beta

should get you there.

@sergiusens Thanks.

@mvo Tried that and I get:

$ snap refresh core --beta
$ snap run --gdb test-snapd-tools.echo my-app
error: cannot find current revision for snap test-snapd-tools: readlink /snap/test-snapd-tools/current: no such file or directory

Gconf is an old, deprecrated settings API and usually the policy violations can be ignored. If your snap is trying to use gconf specifically, I suggest moving over to gsettings instead (this is the standard for many years and something the chromium content API can use (I’m not an electron developer so may need to ask others about that)). I suspect electron is simply trying to use gconf first. In devmode it can use it but in strict mode it would try moving on to something it can use.

Yes, this is because you are launching your application directly (ie, outside of confinement) rather than through the launcher (which launches it under confinement).

Because your snap doesn’t work in devmode, this suggests you are missing something from your snap that is otherwise available on your system. The strace calls can help, but you’re right, it is a firehose of information. I suggest looking for open() calls since that will show you what your snap is trying to use and perhaps not finding. Eg: snap run --strace myapp 2>&1 | grep open

Thanks for the info. I needed to run the snap with snap run myapp rather than just clicking the icon and now I get more information about the crash.