Need help with segfault in mc-installer

I’m having some trouble with the latest build of mc-installer (see: mc-installer git repo)

The build successfully completes but when attempting to run it, I get the following:

snap run mc-installer
/snap/mc-installer/505/launch: line 10: 49564 Segmentation fault      (core dumped) $SNAP/download-launcher.py

Here’s the strace : (Github issue)

And this is what apparmor is reporting:

audit: type=1400 audit(1601867417.707:439): apparmor="DENIED" operation="open" profile="/usr/lib/snapd/snap-confine" name="/etc/pop-os/os-release" pid=104813 comm="snap-confine" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
[217232.093942] audit: type=1400 audit(1601867417.711:440): apparmor="DENIED" operation="open" profile="snap-update-ns.mc-installer" name="/etc/pop-os/os-release" pid=104853 comm="5" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[217232.097171] audit: type=1400 audit(1601867417.711:441): apparmor="DENIED" operation="open" profile="snap.mc-installer.mc-installer" name="/etc/pop-os/os-release" pid=104813 comm="snap-exec" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
[217232.235963] python3[104889]: segfault at 0 ip 0000000000000000 sp 00007ffe5184eea8 error 14 in python3.6[400000+3b4000]
[217232.235968] Code: Bad RIP value.

And finally, here’s the current snapcraft.yaml

name: mc-installer
title: Minecraft Installer
version: '7.1'
summary: A simple installer for Minecraft - Java Edition
description: | 
  A simple installer for Minecraft - Java Edition. 
license: MIT

base: core18
grade: stable
confinement: strict

architectures:
  - build-on: amd64

apps:
  mc-installer:
    extensions:
      - gnome-3-34
    command: launch
    plugs:
      - network
      - opengl
      - audio-playback
      - pulseaudio  # compatibility with snapd <2.41
      - browser-support
      - home
    environment:
      PYTHONPATH: $SNAP/gnome-platform/usr/lib/python3/dist-packages
      JAVA_HOME: $SNAP/usr/lib/jvm/java-8-openjdk-amd64/

parts:
  launcher:
    plugin: dump
    source: scripts

  game:
    plugin: nil
    build-packages:
      - openjdk-8-jre-headless        
      # Fix for "package contains external symlinks" issue
      # https://forum.snapcraft.io/t/resolve-package-contains-external-symlinks-error-when-trying-to-snap/2963
      - ca-certificates
      - ca-certificates-java
    stage-packages:
      - libglu1-mesa
      - libswt-gtk-3-java
      - python3-requests
      - openjdk-8-jre-headless
      - libxss1
      - libgconf2-4
      - libcurl3
  
  # https://snapcraft-utils-library.readthedocs.io/en/latest/lib/cleanup.html
  cleanup:
    after:  # Make this part run last; list all your other parts here
      - game
      - launcher
    plugin: nil
    build-snaps:  # List all content-snaps and base snaps you're using here
      - core18
      - gnome-3-28-1804
    override-prime: |
      set -eux
      for snap in "core18" "gnome-3-28-1804"; do  # List all content-snaps and base snaps you're using here
        cd "/snap/$snap/current" && find . -type f,l -exec rm -f "$SNAPCRAFT_PRIME/{}" \;
      done

The snap was working perfectly before a new build was triggered - nothing changed to it’s baseline so I’m going to assume that something changed with the build service (maybe?). This same error is occurring on Pop! and Solus; so at least it’s consistent.

I can see in strace that there are over 13k references to No such file or directory

I could use some pointers to get moving in the right direction.

TIA.

You can try to run it under gdb viasnap run --gdb (must be run as root), or snap run --experimental-gdbserver. The latter can be run as user, so will likely be more representative. Once in gdb, use bt to see the backtrace. With little luck, you may be able to figure out the root cause or at least get some hints.

1 Like

My guess, python crashes out due the apparmor denials. Looks like pop is using non-standard paths…

Solus is too I guess? That said, version 7.0 works perfectly. It’s with 7.1 (edge) that’s causing the problem.

Still core18, just an update in the build service is rendering this issue as far as I can tell. Solus uses an older version of snapd, vs Pop!

@mborzecki I might be missing something but I’ve reviewed documentation about using gdb and it won’t work. I’ve tried on two different distros and nada.

Seems to work just fine here on Arch. Can you share console output?

What works? The edge version of the snap or gdb?

Both gdb and gdbserver. Since it’s Python that segfaults, you need to toggle detach-on-fork to off in gdb. Then after walking though a number of inferiors you’ll get to:

Continuing.
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
process 1205693 is executing new program: /usr/bin/python3.6

Thread 4.1 "python3" hit Catchpoint 1 (exec'd /usr/bin/python3.6), 0x00007f12d7843090 in ?? () from target:/lib64/ld-linux-x86-64.so.2
(gdb) info inferiors
  Num  Description       Executable
  1    process 1205506   target:/bin/bash
  3    process 1205658   target:/bin/bash
* 4    process 1205693   target:/usr/bin/python3.6

Which next segfaults like so:

Thread 4.1 "python3" received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00007f12d5550dae in ffi_call_unix64 () from target:/usr/lib/x86_64-linux-gnu/libffi.so.6
#2  0x00007f12d555071f in ffi_call () from target:/usr/lib/x86_64-linux-gnu/libffi.so.6
#3  0x00007f12d5f98e6a in ?? () from target:/snap/mc-installer/509/gnome-platform/usr/lib/python3/dist-packages/gi/_gi.cpython-36m-x86_64-linux-gnu.so
#4  0x00007f12d5f9aa48 in ?? () from target:/snap/mc-installer/509/gnome-platform/usr/lib/python3/dist-packages/gi/_gi.cpython-36m-x86_64-linux-gnu.so
#5  0x00000000005a9eec in _PyObject_FastCallKeywords ()
#6  0x000000000050a783 in ?? ()
#7  0x000000000050c1f4 in _PyEval_EvalFrameDefault ()
#8  0x0000000000507f24 in ?? ()
#9  0x0000000000516449 in ?? ()
#10 0x00000000005671ce in PyCFunction_Call ()
#11 0x0000000000511341 in _PyEval_EvalFrameDefault ()
#12 0x0000000000507f24 in ?? ()
#13 0x0000000000509c50 in ?? ()
#14 0x000000000050a64d in ?? ()
#15 0x000000000050c1f4 in _PyEval_EvalFrameDefault ()
#16 0x0000000000509918 in ?? ()
#17 0x000000000050a64d in ?? ()
#18 0x000000000050c1f4 in _PyEval_EvalFrameDefault ()
#19 0x0000000000509918 in ?? ()
#20 0x000000000050a64d in ?? ()
#21 0x000000000050c1f4 in _PyEval_EvalFrameDefault ()
#22 0x0000000000509918 in ?? ()
#23 0x000000000050a64d in ?? ()
#24 0x000000000050c1f4 in _PyEval_EvalFrameDefault ()
#25 0x0000000000509015 in _PyFunction_FastCallDict ()
#26 0x00000000005a4d81 in _PyObject_FastCallDict ()
#27 0x00000000005a5dbe in _PyObject_CallMethodIdObjArgs ()
#28 0x00000000004f6f4d in PyImport_ImportModuleLevelObject ()
#29 0x0000000000514414 in ?? ()
#30 0x0000000000567193 in PyCFunction_Call ()
#31 0x0000000000511341 in _PyEval_EvalFrameDefault ()
#32 0x0000000000507f24 in ?? ()
#33 0x0000000000509c50 in ?? ()
#34 0x000000000050a64d in ?? ()
#35 0x000000000050c1f4 in _PyEval_EvalFrameDefault ()
#36 0x0000000000507f24 in ?? ()
#37 0x0000000000509202 in _PyFunction_FastCallDict ()
#38 0x00000000005a4d81 in _PyObject_FastCallDict ()
#39 0x00000000005a5dbe in _PyObject_CallMethodIdObjArgs ()
#40 0x00000000004f6e9c in PyImport_ImportModuleLevelObject ()
#41 0x000000000050e0ff in _PyEval_EvalFrameDefault ()
#42 0x0000000000507f24 in ?? ()
#43 0x0000000000516449 in ?? ()
#44 0x00000000005671ce in PyCFunction_Call ()
#45 0x0000000000511341 in _PyEval_EvalFrameDefault ()
#46 0x0000000000507f24 in ?? ()

I suspect it’s segfaulting while importing gi or one of the gi wrappers. It’s not entirely clear why, but if you have python debug extensions maybe you’ll be able to debug deeper.

1 Like

Thanks @mborzecki, you helped out a lot. Now I know what to do going forward. Also, based on your post, I was able to determine exactly what the problem was and the fix. See: Gnome-3-34 extension and Python segfault

Basically, this needs to be set:

environment:
      PYTHONPATH: $SNAP_DESKTOP_RUNTIME/usr/lib/python3.6/site-packages

Running version 7.1 w/o issues right now.

1 Like