[lunar] Snaps don't launch due to cgroup issue
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNOME Shell |
New
|
Unknown
|
|||
KDE Base |
New
|
Medium
|
|||
gnome-desktop (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned | ||
gnome-shell (Ubuntu) |
Fix Released
|
Critical
|
Marco Trevisan (Treviño) | ||
kio (Ubuntu) |
Confirmed
|
Critical
|
Unassigned | ||
snapd (Ubuntu) |
Opinion
|
Critical
|
Unassigned |
Bug Description
Hi,
Lunar up to date, Intel+Nvidia GPUs, Ubuntu Wayland or X11 session, hybrid or discrete graphics.
If I click on a snap dash icon, nothing happens.
Tested with Thunderbird, Firefox, Shortwave...
(VS Code seems ok, maybe due to classic confinment?)
I can launch without issue Chrome (deb), Synaptic, GNOME apps, etc.
Recent updates included gnome-shell and libadwaita.
---
I get this type of log for all problematic snaps:
/user.slice/
---
Context:
$ snap --version
snap 2.58.3+23.04ubuntu1
snapd 2.58.3+23.04ubuntu1
series 16
ubuntu 23.04
kernel 6.1.0-16-generic
$ snap list
Nom Version Révision Suivi Éditeur Notes
bare 1.0 5 latest/stable canonical✓ base
code ee2b180d 122 latest/stable vscode✓ classic
core 16-2.58.2 14784 latest/stable canonical✓ core
core18 20230308 2714 latest/stable canonical✓ base
core20 20230207 1828 latest/stable canonical✓ base
core22 20230210 522 latest/stable canonical✓ base
firefox 111.0-2 2432 latest/candidate mozilla✓ -
gimp 2.10.30 393 latest/stable snapcrafters -
gnome-3-28-1804 3.28.0-
gnome-3-38-2004 0+git.6f39565 119 latest/stable canonical✓ -
gnome-42-2204 0+git.09673a5 65 latest/stable canonical✓ -
gtk-common-themes 0.1-81-g442e511 1535 latest/stable/… canonical✓ -
gtk-theme-pocillo 0.14.4.1 5 latest/stable ubuntubudgie -
gtk-theme-
gtk2-common-themes 0.1 13 latest/stable canonical✓ -
hunspell-
kde-frameworks-
kde-frameworks-
kde-frameworks-
libreoffice 7.5.1.2 270 latest/stable canonical✓ -
shortwave 3.0.0 79 latest/stable alexmurray✪ -
snapd 2.58.2 18357 latest/stable canonical✓ snapd
snapd-desktop-
stellarium-daily v1.2 1396 latest/stable t4saha -
thunderbird 102.9.0-1 305 latest/candidate canonical✓ -
vlc 3.0.18 3078 latest/stable videolan✓ -
affects: | ubuntu-release-upgrader (Ubuntu) → snapd (Ubuntu) |
description: | updated |
summary: |
- [lunar] Snaps don't launch in a Wayland session + [lunar] Snaps don't launch due to cgroup issue |
tags: | added: lunar |
Changed in gnome-shell (Ubuntu): | |
assignee: | nobody → Marco Trevisan (Treviño) (3v1n0) |
status: | Confirmed → In Progress |
no longer affects: | snapd (Ubuntu) |
tags: | added: dt-1154 |
Changed in gnome-shell (Ubuntu): | |
milestone: | none → ubuntu-23.04-beta |
Changed in snapd (Ubuntu): | |
status: | New → Won't Fix |
Changed in kio (Ubuntu): | |
status: | New → Confirmed |
Changed in kio (Ubuntu): | |
importance: | Undecided → Critical |
Changed in snapd (Ubuntu): | |
importance: | Undecided → Critical |
Changed in snapd (Ubuntu): | |
status: | Won't Fix → Confirmed |
Changed in gnome-shell (Ubuntu): | |
status: | In Progress → Fix Committed |
Changed in gnome-shell: | |
status: | Unknown → New |
Changed in snapd (Ubuntu): | |
status: | Confirmed → Opinion |
Changed in kde-baseapps: | |
importance: | Unknown → Medium |
status: | Unknown → New |
SUMMARY
Since cgroup is created in kio after process startup, there is a race condition present if started process forks and starts some children before cgroup creation is processed.
Currently, situation sometimes, depending on various circumstances, may be following:
1. kio starts new process via KProcessRunner class.
2. Started process runs and forks, creating one or more children.
3. kio creates new cgroup and puts started process to this new cgroup. All children created by started process stay in current cgroup.
STEPS TO REPRODUCE
1. Try starting via KProcessRunner class applications which fork soon after launch.
Modern firefox, for example.
If application forks and parent exits, it's even better.
OBSERVED RESULT
Sometimes created cgroup would contain only parent process without any it's children. If parent process quits, it may result even into an empty cgroup. Children of launched process would be left in the cgroup of parent of launched process. Should not be reliably reproducible.
EXPECTED RESULT
Cgroup should contain both started process and all it's children reliably.
ADDITIONAL INFORMATION
I did not try reproducing it.
Currently, cgroup created when process is already running, and if this process creates some children fast, it may lead to described issue. Here's the link to code:
https:/ /invent. kde.org/ frameworks/ kio/-/blob/ 8d6b306f5859202 30acecd19903325 f6f0387b8e/ src/gui/ kprocessrunner. cpp#L226
Function 'registerCGroup()' is called in 'KProcessRunner ::slotProcessSt arted() ' slot, which is invoked after process started, within some undetermined timeframe.
In my opinion, proper way to start process in new cgroup in order to fix this issue looks like following:
1. KProcessRunner forks.
2. Fork sets up cgroup, puts itself into it, waits until it's confirmed that OS finished moving it into new cgroup. Optionally between forking and setting up cgroup, it may exec into some helper which would setup cgroup.
3. Fork (or helper used to setup cgroup, if one is used) execs into the new process. Since it's already running in new cgroup before exec, when new process is started it's already contained in new cgroup, and even if first thing it does is fork() call, all children would be contained in that new cgroup as well, without any race conditions.
AFAIK, systemd-run actually setups cgroup and reliably puts requested process and all it's children into newly created cgroup, but I might be wrong. Not sure which interfaces are available from systemd via dbus or some library for starting process similarly to systemd-run.