SIGSEGV (Address boundary error)

Hi,

I’m building my first snap, and for such an special occasion I choose this Amstrad/Spectrum emulator. I’ve been following the “Create your first snap” guide and search within this forum for some of the issues I’ve found during the process.

At this point, I’m not sure what is failing and how I can solve it. Any advice (also in good practices) is welcome.

After running snapcraft
and later sudo snap install --devmode retro-virtual-machine_0.1_amd64.snap
I get 'retro-virtual-machine' terminated by signal SIGSEGV (Address boundary error).

Here is my snapcraft.yaml

name: retro-virtual-machine 
base: core18 # the base snap is the execution environment for this snap
version: '0.1'
summary: Emulator of the Amstrad CPC and the ZX Spectrum home computers # 79 char long summary
description: |
  Emulator of the Amstrad CPC and the ZX Spectrum home computers.
  Maintainer: Juan Carlos González Amestoy <rvm@retrovirtualmachine.org>

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

apps:
  retro-virtual-machine:
    command: usr/bin/RetroVirtualMachine
    desktop: usr/share/applications/rvm.desktop
    plugs:
      - desktop
      - desktop-legacy
      - wayland
      - unity7
      - home
      - opengl
      - pulseaudio

parts:
  retro-virtual-machine:
    source: https://static.retrovm.org/release/beta1/linux/x64/RetroVirtualMachine.2.0.beta-1.r7.linux.x64.deb
    plugin: dump
    source-type: deb
    stage-packages:
      - libx11-6
      - libxinerama1
      - libgl1
      - libxi6

install the snappy-debug snap … open a second terminal, start snappy-debug in there and run your app in the first terminal, that might give you some clues …

Hi Ogra, thanks for the suggestion.

This is the output of snappy-debug

= AppArmor =
Time: Nov  2 09:18:13
Log: apparmor="ALLOWED" operation="open" profile="snap.retro-virtual-machine.retro-virtual-machine" name="/run/udev/data/c116:4" pid=65772 comm="RetroVirtualMac" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /run/udev/data/c116:4 (read)
Suggestions:
* adjust program to use $SNAP_DATA
* adjust program to use /run/shm/snap.$SNAP_NAME.*
* adjust program to use /run/snap.$SNAP_NAME.*
* adjust snap to use snap layouts (https://forum.snapcraft.io/t/snap-layouts/7207)
* add 'hardware-observe' to 'plugs'

I’ve already added hardware-observe to plugs, but I still get suggestion.

did you also connect it with the snap connect command ?

I’m not sure if I’m doing something in the wrong order here…

After running

sudo snap connect retro-virtual-machine:hardware-observe :hardware-observe

The command snappy-debug does not show anything after I run retro-virtual-machine (still failing with the same error). I’ve snapcraft and install the snap again, but the output that snappy-debug was giving before is gone.

I got it working here.

You’re missing some GTK libs, which I discovered by running snap run --strace retro-virtual-machine and noting the errors near the bottom:

[pid 2914151] openat(AT_FDCWD, "/snap/retro-virtual-machine/x2/usr/lib/libgtk-3.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 2914151] openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 10
[pid 2914151] fstat(10, {st_mode=S_IFREG|0644, st_size=103358, ...}) = 0
[pid 2914151] mmap(NULL, 103358, PROT_READ, MAP_PRIVATE, 10, 0) = 0x7fc45a31c000
[pid 2914151] close(10)                 = 0                                                                                                                                                                   
[pid 2914151] access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
[pid 2914151] openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libgtk-3.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 2914151] openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libgtk-3.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 2914151] openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libgtk-3.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 2914151] openat(AT_FDCWD, "/lib/libgtk-3.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 2914151] openat(AT_FDCWD, "/usr/lib/libgtk-3.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 2914151] munmap(0x7fc45a31c000, 103358) = 0
[pid 2914151] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} ---
[pid 2914197] <... ppoll resumed> <unfinished ...>) = ?
[pid 2914197] +++ killed by SIGSEGV (core dumped) +++
+++ killed by SIGSEGV (core dumped) +++
error: signal: segmentation fault

Here’s the YAML I tweaked.

name: retro-virtual-machine 
base: core18 # the base snap is the execution environment for this snap
version: '2.0.beta-1.r7'
summary: Emulator of the Amstrad CPC and the ZX Spectrum home computers # 79 char long summary
description: |
  Emulator of the Amstrad CPC and the ZX Spectrum home computers.
  Maintainer: Juan Carlos González Amestoy <rvm@retrovirtualmachine.org>

grade: stable
confinement: strict

apps:
  retro-virtual-machine:
    extensions: [gnome-3-34]
    command: usr/bin/RetroVirtualMachine
    desktop: usr/share/applications/rvm.desktop
    environment:
      LD_LIBRARY_PATH: "$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio:$LD_LIBRARY_PATH"
    plugs:
      - desktop
      - desktop-legacy
      - wayland
      - unity7
      - home
      - opengl
      - audio-playback
      - joystick

parts:
  retro-virtual-machine:
    source: https://static.retrovm.org/release/beta1/linux/x64/RetroVirtualMachine.$SNAPCRAFT_PROJECT_VERSION.linux.x64.deb
    plugin: dump
    source-type: deb
    stage-packages:
      - libx11-6
      - libxinerama1
      - libgl1
      - libxi6
      - libpulse0

1 Like

Thanks Alan,

If I snapcraft your yaml, I still get errors (what I did not expect to happen, since it works for you)

Building gnome-3-34-extension 
make -j2
gcc -Wall -O2 -o bindtextdomain.so -fPIC -shared ./../src/bindtextdomain.c -ldl
./../src/bindtextdomain.c:5:10: fatal error: errno.h: No such file or directory
 #include <errno.h>
          ^~~~~~~~~
compilation terminated.
Makefile:20: recipe for target 'desktop-launch' failed
make: *** [desktop-launch] Error 1

I’ve search for errno.h and made sure that libc6-dev is installed in my system, as well as one of the packages for the stage-packages, but none of them worked. Is it maybe a missing snap in my side?

I have some questions for better understanding what I was missing:

  • grade: stable and confinement: strict. Do they have an impact instead of my first approach with devel and devmode? I was assuming that devel and devmode were fine during development until I would get a working snap

  • extensions: [gnome-3-34]. I understand that this is for the GTK support, right? Is there a difference if I would choose to install the GTK libraries?

  • environment: LD_LIBRARY_PATH: ... I see that this is related to pulseaudio. Is it a standard practice or only for this specific snap?

Thanks!

I used snapcraft --use-lxd to build the snap, ensuring the snap builds in an Ubuntu 18.04 container. How are you using snapcraft, and on what platform?
I just changed grade and confinement because I got it working. No point having them in devmode / devel when it works fine stable/confined.
The extension is a helper which means you don’t need to stage the GTK libs, and as such reduces the size of the snap, as it relies on the GNOME content snap. It also creates a launcher and sets up default plugs and other useful pieces to save effort on your part.
The LD_LIBRARY_PATH is necessary because pulseaudio puts its .so files in a weird place. Not specific to your app.

Clear! I was not using --use-lxd (building on 20.04) since I did not know about it. For a first snap, I already learnt quite a few things :slight_smile:

Thanks for the answers to the different questions. Is not possible to have a helper for puslseaudio as we have for GNOME and avoid the variable modification within the yaml?

Now that I managed to build it, time to publish it! :smiley:

1 Like

if you use the gnome extension, it already ships libpulse-common (from the libpulse0 package) so you should not need to separately use a stage-packages entry for it and i’d actually also expect the library path to point to the correct thing when using the desktop-launch script from the extension …

1 Like

You are right. I’ve tried to build without libpulse0 and the environment variable modification and “it still makes delicious 8bit noises” after installing :smiley:

2 Likes

Given I had (and still have) Sinclair Spectrums and Amstrad CPCs, it pleases me to see this snap :slight_smile:

If more people snapped emulators and games, the world would be a better place :smiley:

2 Likes

And there it goes!

I could not use retro-virtual-machine, it seems to be used. I’ll contact the original developer to check with him if he registered the Snap name.

A side question, the Snap page of the Ubuntu Software app says that I’m the developer, what it is not true, is there a way to replace that field so I can give credit to the right person?

1 Like