unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#37308: guix weston-launch segfaults, /usr/bin/weston-launch does not -- why?
@ 2019-09-05 12:17 Bengt Richter
  2019-09-05 20:22 ` Tobias Geerinckx-Rice via Bug reports for GNU Guix
  0 siblings, 1 reply; 2+ messages in thread
From: Bengt Richter @ 2019-09-05 12:17 UTC (permalink / raw)
  To: 37308

I used guix strace and /usr/bin/strace to try to diagnose weston-launch,
from grepping my history:

  531  /usr/bin/strace -fyk -o wes-launch-fyk $(which weston-launch|xargs readlink -f)
  553  /usr/bin/strace -fyk -o wes-launch-fyk-usr $(which /usr/bin/weston-launch|xargs readlink -f)

I used /usr/bin/strace because it still had the -k option:

$ diff -u <(/usr/bin/strace -h) <(strace -h)
--- /dev/fd/63	2019-09-05 01:38:07.086388920 -0700
+++ /dev/fd/62	2019-09-05 01:38:07.086388920 -0700
@@ -7,7 +7,6 @@
 Output format:
   -a column      alignment COLUMN for printing syscall results (default 40)
   -i             print instruction pointer at time of syscall
-  -k             obtain stack trace between each syscall
   -o file        send trace output to FILE instead of stderr
   -q             suppress messages about attaching, detaching, etc.
   -r             print relative timestamp
$ 

Could we have it back, or is it a security issue? Anyway, it does a LOT
of work, so it makes the trace very slow -- but still useful.

The first thing I noticed was a permission problem. 
 Note difference between trace logs (no EACCES errors for /usr/bin/weston-launch):

$ grep EACC wes-launch-fyk
3989  openat(AT_FDCWD, "/dev/input/event3", O_RDWR|O_NONBLOCK|O_CLOEXEC) = -1 EACCES (Permission denied)
3989  openat(AT_FDCWD, "/dev/input/event9", O_RDWR|O_NONBLOCK|O_CLOEXEC) = -1 EACCES (Permission denied)
3989  openat(AT_FDCWD, "/dev/input/event10", O_RDWR|O_NONBLOCK|O_CLOEXEC) = -1 EACCES (Permission denied)
3989  openat(AT_FDCWD, "/dev/input/event0", O_RDWR|O_NONBLOCK|O_CLOEXEC) = -1 EACCES (Permission denied)
3989  openat(AT_FDCWD, "/dev/input/event2", O_RDWR|O_NONBLOCK|O_CLOEXEC) = -1 EACCES (Permission denied)
3989  openat(AT_FDCWD, "/dev/input/event1", O_RDWR|O_NONBLOCK|O_CLOEXEC) = -1 EACCES (Permission denied)
3989  openat(AT_FDCWD, "/dev/input/event7", O_RDWR|O_NONBLOCK|O_CLOEXEC) = -1 EACCES (Permission denied)
3989  openat(AT_FDCWD, "/dev/input/event11", O_RDWR|O_NONBLOCK|O_CLOEXEC) = -1 EACCES (Permission denied)
3989  openat(AT_FDCWD, "/dev/input/event12", O_RDWR|O_NONBLOCK|O_CLOEXEC) = -1 EACCES (Permission denied)
3989  openat(AT_FDCWD, "/dev/input/event13", O_RDWR|O_NONBLOCK|O_CLOEXEC) = -1 EACCES (Permission denied)
3989  openat(AT_FDCWD, "/dev/input/event14", O_RDWR|O_NONBLOCK|O_CLOEXEC) = -1 EACCES (Permission denied)
3989  openat(AT_FDCWD, "/dev/input/event15", O_RDWR|O_NONBLOCK|O_CLOEXEC) = -1 EACCES (Permission denied)
3989  openat(AT_FDCWD, "/dev/input/event16", O_RDWR|O_NONBLOCK|O_CLOEXEC) = -1 EACCES (Permission denied)
3989  openat(AT_FDCWD, "/dev/input/event4", O_RDWR|O_NONBLOCK|O_CLOEXEC) = -1 EACCES (Permission denied)
3989  openat(AT_FDCWD, "/dev/input/event8", O_RDWR|O_NONBLOCK|O_CLOEXEC) = -1 EACCES (Permission denied)
3989  openat(AT_FDCWD, "/dev/input/event5", O_RDWR|O_NONBLOCK|O_CLOEXEC) = -1 EACCES (Permission denied)
3989  openat(AT_FDCWD, "/dev/input/event6", O_RDWR|O_NONBLOCK|O_CLOEXEC) = -1 EACCES (Permission denied)
3989  ioctl(4</dev/dri/card0>, DRM_IOCTL_DROP_MASTER, 0) = -1 EACCES (Permission denied)
$ 
$ grep EACC wes-launch-fyk-usr
$ 
(The above grep found no (! :) EACCES problems for /usr/bin/weston-launch in the strace ouput)

Here's my attempt to see what kind of errors happened:

$ egrep -ohe '-1 E.*' wes-launch-fyk|sort|uniq -c|sort -h
      1 -1 EPERM (Operation not permitted)
      2 -1 ENOTTY (Inappropriate ioctl for device)
     18 -1 EACCES (Permission denied)
     40 -1 EINVAL (Invalid argument)
    640 -1 ENOENT (No such file or directory)
$ 

EINVALs look like they may mostly be legitimate probes for input devices,
and ENOENTs are mostly walking through all the places to look for config data
-- which seems like someone could memoize away once at login time so a program
would usually just have to do a single am-I-newer-than-my-memoized-config-data check.

The /usr/bin/weston-launch succeeded in bringing up the gui weston/wayland desktop
with an icon for starting a terminal, so naturally it did a lot more, and bumped
into more things. Some look like bugs, but I'm not sure using /usr/bin/strace like

    /usr/bin/strace -fyk -o wes-launch-fyk $(which weston-launch|xargs readlink -f)

was not itself producing some errors. Amazing tool anyway :)

$ egrep -ohe '-1 E.*' wes-launch-fyk-usr|sort|uniq -c|sort -h
      1 -1 EBADF (Bad file descriptor)
      1 -1 EPERM (Operation not permitted)
      3 -1 ENOTTY (Inappropriate ioctl for device)
     68 -1 EAGAIN (Resource temporarily unavailable)
     86 -1 EINVAL (Invalid argument)
    984 -1 ENOENT (No such file or directory)
$
I included the -y option so you can see the files as </path/to/file> in the strace,
so it seems /dev/dri/card0 produced EPERM for both versions of weston-launch.

Idk what _IOC does  to /dev/tty1, but I guess the <anon_inode:[eventpoll]> might come from
exiting the gui desktop using Ctl-Alt-Backspace.

BTW, I have noticed  that on returning to console after such an exit, I lose write permission
to /dev/stderr -- don't know what that means, but I get it back if I log out and log back in.

$ egrep '(EBADF|EPERM|ENOTTY)' wes-launch-fyk wes-launch-fyk-usr
wes-launch-fyk:3989  ioctl(0</dev/tty1>, _IOC(_IOC_NONE, 0x4b, 0x51, 0), 0x1) = -1 ENOTTY (Inappropriate ioctl for device)
wes-launch-fyk:3990  ioctl(12</dev/dri/card0>, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, 0x7fffc5200270) = -1 EPERM (Operation not permitted)
wes-launch-fyk:3989  ioctl(0</dev/tty1>, _IOC(_IOC_NONE, 0x4b, 0x51, 0), 0) = -1 ENOTTY (Inappropriate ioctl for device)
wes-launch-fyk-usr:5421  ioctl(0</dev/tty1>, _IOC(_IOC_NONE, 0x4b, 0x51, 0), 0x1) = -1 ENOTTY (Inappropriate ioctl for device)
wes-launch-fyk-usr:5422  ioctl(15</dev/dri/card0>, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, 0x7ffdb7571460) = -1 EPERM (Operation not permitted)
wes-launch-fyk-usr:5422  epoll_ctl(17<anon_inode:[eventpoll]>, EPOLL_CTL_DEL, 19, NULL) = -1 EBADF (Bad file descriptor)
wes-launch-fyk-usr:5421  ioctl(0</dev/tty1>, _IOC(_IOC_NONE, 0x4b, 0x51, 0), 0) = -1 ENOTTY (Inappropriate ioctl for device)
wes-launch-fyk-usr:5421  ioctl(0</dev/tty1>, DRM_IOCTL_DROP_MASTER, 0) = -1 ENOTTY (Inappropriate ioctl for device)
$

The output logged to the console tty1 can be extracted from the strace,
along with the segfault:

egrep '/dev/tty1|SEG' wes-launch-fyk|tail -20

3990  write(2</dev/tty1>, "event5: opening input device '/d"..., 83) = 83
3990  write(2</dev/tty1>, "[00:35:11.032] ", 15) = 15
3990  write(2</dev/tty1>, "event5  - failed to create input"..., 60) = 60
3989  write(2</dev/tty1>, "Error opening device /dev/input/"..., 58) = 58
3990  write(2</dev/tty1>, "[00:35:11.100] ", 15) = 15
3990  write(2</dev/tty1>, "event6: opening input device '/d"..., 83) = 83
3990  write(2</dev/tty1>, "[00:35:11.110] ", 15) = 15
3990  write(2</dev/tty1>, "event6  - failed to create input"..., 60) = 60
3990  write(2</dev/tty1>, "[00:35:11.136] ", 15) = 15
3990  write(2</dev/tty1>, "warning: no input devices on ent"..., 191) = 191
3990  write(2</dev/tty1>, "[00:35:11.144] ", 15) = 15
3990  write(2</dev/tty1>, "failed to create input devices\n", 31) = 31
3990  close(0</dev/tty1> <unfinished ...>
3990  --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x7f2ee04e23c4} ---
3990  +++ killed by SIGSEGV (core dumped) +++
3989  wait4(-1, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGSEGV && WCOREDUMP(s)}], 0, NULL) = 3990
3989  ioctl(0</dev/tty1>, _IOC(_IOC_NONE, 0x4b, 0x51, 0), 0) = -1 ENOTTY (Inappropriate ioctl for device)
3989  ioctl(0</dev/tty1>, KDSKBMODE, 0x3) = 0
3989  ioctl(0</dev/tty1>, KDSETMODE, 0) = 0
3989  ioctl(0</dev/tty1>, VT_SETMODE, 0x7ffeaa561f84) = 0

I still haven't nailed just where it happens, but I need some zs right now :)

Any help getting my guix weston-launch running would be greatly appreciated!

BTW, icecat sort of runs on top of /usr/bin/weston-launch, but it crashes seemingly on any save-as type of action,
blasting all the way back to the login console, not just back to the weston-terminal from which it was launched.

BTW2, I finally got icecat to show useful output after shotgunning like:

 guix package -i nss-certs
 guix upgrade icecat
 guix install fontconfig
 guix install libxfont
 guix install font-dejavu -->> this finally gave icecat a font
 guix install moka-icon-theme
 guix install hicolor-icon-theme
 guix install less
 guix package -i libsigsegv

I think it would be nice to be advised that font-dejavu may solve
the hex-box-font problem for a novice ;-)

installed mozjs also, but must have logged it elsewhere
(it's of course in guix package -l)

Anyway, TIA

Regards,
Bengt Richter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#37308: guix weston-launch segfaults, /usr/bin/weston-launch does not -- why?
  2019-09-05 12:17 bug#37308: guix weston-launch segfaults, /usr/bin/weston-launch does not -- why? Bengt Richter
@ 2019-09-05 20:22 ` Tobias Geerinckx-Rice via Bug reports for GNU Guix
  0 siblings, 0 replies; 2+ messages in thread
From: Tobias Geerinckx-Rice via Bug reports for GNU Guix @ 2019-09-05 20:22 UTC (permalink / raw)
  To: Bengt Richter; +Cc: 37308

[-- Attachment #1: Type: text/plain, Size: 375 bytes --]

Bengt,

Bengt Richter 写道:
> Could we have [strace -k] back, or is it a security issue?

Ask upstream, they disabled[0] it by default, but I can't see how 
it could ever be a ‘security issue’.  strace isn't installed 
setuid.

Thanks for noticing,

T G-R

[0]: 
https://github.com/strace/strace/blob/172dc2fedd23d4debf65252eb3aafe0df70a1567/NEWS#L200

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-05 20:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-05 12:17 bug#37308: guix weston-launch segfaults, /usr/bin/weston-launch does not -- why? Bengt Richter
2019-09-05 20:22 ` Tobias Geerinckx-Rice via Bug reports for GNU Guix

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).