Need help with segmentation fault on wayland

When running the bzoing snap on Ubuntu 17.10 on Wayland, I get this:

[35533.934227] python3[9575]: segfault at 0 ip 00007f168c2c3dd6 sp 00007ffccdb73ce0 error 4 in libwayland-client.so.0.3.0[7f168c2be000+c000]

Not sure if this is caused by some missing snapcraft.yaml dependencies or configuration, since bzoing runs fine on 17.10 inside virtualenv with --system-site-packages.

my current snapcraft.yaml: https://github.com/lapisdecor/bzoing/blob/master/snap/snapcraft.yaml

The snap runs fine on xorg. Any help would be very welcome.

Try checking for seccomp denials by running snappy-debug while you launch and use your snap:

sudo snap install snappy-debug
snappy-debug.scanlog bzoing

Your shell will now print the confinement denials until you use ctrl+c to stop it, so you’ll need a second terminal to run your app; or you can use the launcher icon for your app in your desktop-environment’s menu if there is one and you don’t need to watch the output of your app while you monitor the scanlog.

Alternatively there might be log messages in /var/log/syslog

I get this:

INFO: following '/var/log/syslog'. If have dropped messages, use:
INFO: $ sudo journalctl —output=short —follow —all | sudo snappy-debug.security scanlog
kernel.printk_ratelimit = 0
= AppArmor =
Time: Dec  3 16:30:29
Log: apparmor="DENIED" operation="open" profile="snap.bzoing.bzoing" name="/etc/default/nss" pid=3270 comm="xdg-user-dirs-u" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /etc/default/nss (read)
Suggestions:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON
* add 'account-control' to 'plugs'

= AppArmor =
Time: Dec  3 16:30:29
Log: apparmor="DENIED" operation="mkdir" profile="snap.bzoing.bzoing" name="/home/luis/Downloads/" pid=3270 comm="xdg-user-dirs-u" requested_mask="c" denied_mask="c" fsuid=1000 ouid=1000
File: /home/luis/Downloads/ (write)
Suggestion:
* adjust program to write to $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON

= AppArmor =
Time: Dec  3 16:30:29
Log: apparmor="DENIED" operation="mkdir" profile="snap.bzoing.bzoing" name="/home/luis/Templates/" pid=3270 comm="xdg-user-dirs-u" requested_mask="c" denied_mask="c" fsuid=1000 ouid=1000
File: /home/luis/Templates/ (write)
Suggestion:
* adjust program to write to $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON

= AppArmor =
Time: Dec  3 16:30:29
Log: apparmor="DENIED" operation="mkdir" profile="snap.bzoing.bzoing" name="/home/luis/Public/" pid=3270 comm="xdg-user-dirs-u" requested_mask="c" denied_mask="c" fsuid=1000 ouid=1000
File: /home/luis/Public/ (write)
Suggestion:
* adjust program to write to $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON

= AppArmor =
Time: Dec  3 16:30:29
Log: apparmor="DENIED" operation="mkdir" profile="snap.bzoing.bzoing" name="/home/luis/Documents/" pid=3270 comm="xdg-user-dirs-u" requested_mask="c" denied_mask="c" fsuid=1000 ouid=1000
File: /home/luis/Documents/ (write)
Suggestion:
* adjust program to write to $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON

= AppArmor =
Time: Dec  3 16:30:29
Log: apparmor="DENIED" operation="mkdir" profile="snap.bzoing.bzoing" name="/home/luis/Music/" pid=3270 comm="xdg-user-dirs-u" requested_mask="c" denied_mask="c" fsuid=1000 ouid=1000
File: /home/luis/Music/ (write)
Suggestion:
* adjust program to write to $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON

= AppArmor =
Time: Dec  3 16:30:29
Log: apparmor="DENIED" operation="mkdir" profile="snap.bzoing.bzoing" name="/home/luis/Pictures/" pid=3270 comm="xdg-user-dirs-u" requested_mask="c" denied_mask="c" fsuid=1000 ouid=1000
File: /home/luis/Pictures/ (write)
Suggestion:
* adjust program to write to $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON

= AppArmor =
Time: Dec  3 16:30:29
Log: apparmor="DENIED" operation="mkdir" profile="snap.bzoing.bzoing" name="/home/luis/Videos/" pid=3270 comm="xdg-user-dirs-u" requested_mask="c" denied_mask="c" fsuid=1000 ouid=1000
File: /home/luis/Videos/ (write)
Suggestion:
* adjust program to write to $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON

= AppArmor =
Time: Dec  3 16:30:31
Log: apparmor="DENIED" operation="open" profile="snap.bzoing.bzoing" name="/home/luis/.config/dconf/user" pid=3253 comm="python3" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
File: /home/luis/.config/dconf/user (read)
Suggestion:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON

But I don’t get why is it creating those directories. (Videos, etc)
Can you give me an example on how to adjust the program to read necessary files? Do I have to set environment variables? Or do I have to include the gsettings plug?

none of those should be fatal. Usually a segfault on an otherwise working branch only in a snap indicates a problem with confinement in some way, but those specific denials in your pasted log should be ok to ignore for now. You can try using strace to see what it is trying to do when it dies - Stracing snap commands

I get this from strace:

(bzoing-now:3632): libappindicator-WARNING : Unable to get the session bus: Failed to execute child process "dbus-launch" (No such file or directory)

(bzoing-now:3632): LIBDBUSMENU-GLIB-WARNING : Unable to get session bus: Failed to execute child process "dbus-launch" (No such file or directory)

and then strace hangs. It doesn’t seem to get to the segfault and the icon doesn’t show (which normally does, the crash only happens when I click the menu (and I cant click it because it doesn’t show. These two are warnings, not sure if they are the ones provoking the segfault. Any ideas?

the post I linked above details an strace incantation which doesn’t hang as readily. There are conflicts with some of strace's interceptions and snapped apps which causes them to hang early rather than progress to the bug you’re trying to find. The solution is to tell strace to not monitor for a few specific syscalls.

This one we can probably allow somewhere else. I’ve taken a todo to look into it.

It is interesting that it is trying to create these directories. The ‘home’ interface would allow these to work. Curious if your desktop is translated but the snap isn’t getting the locale of your desktop…

For this you need the gsettings interface.

I think my program doesn’t require the home plug. It only writes to one file which is in /home/user/.local/share/bzoing/somefile. It was writing well to it before adding the home plug and the home plug made the snap write new default home/user/subdirectories to my system (not the snap home), in English, so my system now has duplicate directories for Music, Video, etc. the ones I had, in Portuguese, and the new ones. I suspect this behavior may come from desktop helpers, but its new since before the snap didn’t try to write this directories.
The segfault is still happening after I tried adding the home and gsettings plugs.

Hi, we have the same crash problem with Remmina under Wayland with both Ubuntu 17.10 and arch.

So I wrote a new test GTK app with crashes exactly with the following error.

mar 19 20:09:20 ub1710 kernel: prova1[2476]: segfault at 0 ip 00007f0c8dcc9dd6 sp 00007ffcd6197dd0 error 4 in libwayland-client.so.0.3.0[7f0c8dcc4000+c000]

Hoping this can help you to fix it, I developed a simple test&crash SNAP application here:
https://github.com/giox069/snapcrashbug

The only workaround I found is to disable wayland, as explained on my README.md

Thank you

@giox069 I believe this is a known problem with the Xenial GTK3 packages combined with Wayland. I’ve encountered similar issues. The solution for now is to eschew the default GTK packages in favour of the Gnome Platform snap:

parts:
    gnome-platform:
        after: [desktop-gnome-platform]
        plugin: nil
        prepare: |
            echo "deb http://ppa.launchpad.net/ubuntu-desktop/gnome-3-26/ubuntu xenial main" | tee /etc/apt/sources.list.d/gnome-3-24.list
            apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 399B698EEA9EF163B6F9A0F62CC98497A1231595
            apt-get update
            apt-get upgrade -yyq
        prime: [-*]

    my-part:
        after: [gnome-platform]
        build-packages:
        - libgtk-3-dev # and any other build packages
        stage-packages:
        - ... # GTK and Gnome packages are provided by the platform snap
        - ... # so do not include them here.

# This is important for your snap to access the gnome-platform snap
plugs:
    gnome-3-26-1604:
        interface: content
        target: $SNAP/gnome-platform
        default-provider: gnome-3-26-1604:gnome-3-26-1604

apps:
    my-app:
        command: desktop-launch $SNAP/usr/bin/myapp
        plugs:
        - desktop
        - desktop-legacy
        - gsettings  # most GTK3 or Gnome apps use this for configuration
        - opengl     # safer to include it if you're unsure
        - pulseaudio # maybe? depends on your app
        - x11
        - wayland