~exec64/imv#8: 
segfault from tty

this isn't a practical issue, but running imv with no arguments from a tty segfaults on my system. is the intended behavior to print an error message, like "cannot open display: $" (or should that be the behavior)?

Status
REPORTED
Submitter
~nissa
Assigned to
No-one
Submitted
1 year, 2 months ago
Updated
3 months ago
Labels
No labels applied.

~itaranto 3 months ago

It seems it tries to use the X11 version:

imv-x11: ../imv-v4.4.0/src/x11_window.c:109: imv_window_create: Assertion `window->x_display' failed.
Aborted (core dumped)

~nissa 3 months ago

/* imv.c, starting at line 1207 */
static bool setup_window(struct imv *imv)
{
  imv->window = imv_window_create(imv->initial_width, imv->initial_height, "imv");

  if (!imv->window) {
    imv_log(IMV_ERROR, "Failed to create window\n");
    return false;
  }

the callee handles errors, so the immediate fix is replacing these assertions (there's one in wl_window.c too) with propogating the error upward.

there's several other asserts in imv_window_create which also seem like they can fail (and at a quick glance, many other asserts throughout the codebase). this would be fine, if not a little unfriendly for the few users who'd be reading them, if asserts were unconditionally compiled. however, my understanding of assertions in the c standard library is that conditionally compiling them is a fundamental feature.

a deeper fix to the issue revealed by this would be to go through every assertion and make sure that it's probably not possible to hit, adding error handling as needed.

~smasher164 3 months ago

Is this caused by a wlroots update? https://github.com/swaywm/sway/issues/7398 suggests that even chromium and mpv are broken on wayland.

~smasher164 referenced this from #44 3 months ago

~itaranto 3 months ago

Is this caused by a wlroots update? https://github.com/swaywm/sway/issues/7398 suggests that even chromium and mpv are broken on wayland.

This cannot be caused by wlroots since the error comes from imv-x11 not imv-wayland.

When running on a TTY it defaults to imv-x11 since there's not WAYLAND_DISPLAY isn't defined:

#!/bin/sh
if [ -n "${WAYLAND_DISPLAY}" ]; then
  exec imv-wayland "$@"
else
  exec imv-x11 "$@"
fi

~itaranto 3 months ago

Oh, if you mean the whole assert thing, then yes. But the root cause of both issues seem to be different.

~nissa 3 months ago

i submitted a patch for this immediate fix here: https://lists.sr.ht/~exec64/imv-devel/patches/38654

Register here or Log in to comment, or comment via email.