Skip to content

Segmentation fault on Ubuntu 21.10

Orage crashes with segmentation fault on Ubuntu 21.10. Segmentation fault occurs while while detecting running Orage instances. This occurs only when XDG_RUNTIME_DIR environment variable is set (currently XDG_RUNTIME_DIR=/run/user/1000), when this variable is unset then program works normally.

Failing function is XGetSelectionOwner in check_orage_alive:

static gboolean check_orage_alive(void)
{
    if (XGetSelectionOwner(gdk_x11_get_default_xdisplay(),
                           gdk_x11_atom_to_xatom(atom_alive)) != None)
        return(TRUE); /* yes, we got selection owner, so orage must be there */
    else /* no selction owner, so orage is not running yet */
        return(FALSE);
}

https://gitlab.xfce.org/apps/orage/-/blob/master/src/main.c#L550

GDB shows following backtrace:

Thread 1 "orage" received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in  ()
#1  0x00007ffff7107f4a in g_hash_table_lookup () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007ffff76ea008 in gdk_x11_atom_to_xatom_for_display () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#3  0x0000555555567b42 in check_orage_alive () at ../../orage.xfce/src/main.c:550
#4  main (argc=<optimized out>, argv=<optimized out>) at ../../orage.xfce/src/main.c:588

Attached extracted failing code part and makefile for testing. Makefile gdk_atoms_test.c