Subject: nxagent fails to run with "Could not open default font 'fixed'"

From: devsk <[email-masked]>
Date: Sun, 31 May 2015 20:35:57 +0000 (UTC)

Package: nx-libsVersion: 3.5.0.30Distro: Gentoo ~amd64, fully updated.x2goclient: 4.0.3.2x2server: 4.0.1.19nx-libs (package nx in gentoo): 3.5.0.30fontsproto: 2.1.3libXfont: 1.5.1xorg-server: 1.17.1All font packages for xorg-x11 are installed and fonts.dir and fonts.alias files are correctly present and readable.Detailed troubleshooting:  https://forums.gentoo.org/viewtopic-p-7755384.html
The client connects and the server spawns the nxagent but then the session is unexpectedly terminated. Looking at the server side log, we see:
Info: Using shared memory parameters 1/1/0/0K. Info: Using alpha channel in render extension. Info: Not using local device configuration changes. keyboard file created Error: Aborting session with 'Could not open default font 'fixed''. Session: Aborting session at 'Tue May 26 23:22:22 2015'. Session: Session aborted at 'Tue May 26 23:22:22 2015'. 
I ran the nxagent through strace -ff -tt -v and its clear that it loads all fonts (at least it finds all font.alias and reads them fine) correctly. None of the children it spawns run into any issues with missing files or folders. The snippet below (you can read longer strace on gentoo forum post):
22:11:10.608011 open("/usr/share/fonts/100dpi/fonts.alias", O_RDONLY) = 4 22:11:10.608108 fstat(4, {st_mode=S_IFREG|0644, st_size=3154, ...}) = 0 22:11:10.608217 fstat(4, {st_mode=S_IFREG|0644, st_size=3154, ...}) = 0 22:11:10.608308 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29ca5a9000 22:11:10.608398 read(4, "lucidasans-bolditalic-8 -b&h-luc"..., 4096) = 3154 22:11:10.608496 brk(0x1f01000)          = 0x1f01000 22:11:10.608688 read(4, "", 4096)       = 0 22:11:10.608781 close(4)                = 0 22:11:10.608868 munmap(0x7f29ca5a9000, 4096) = 0 22:11:10.609148 write(2, "Error: Aborting session with '", 30Error: Aborting session with ') = 30 22:11:10.609277 write(2, "Could not open default font 'fix"..., 35Could not open default font 'fixed') = 35 22:11:10.609395 write(2, "'.\n", 3'. )     = 3 
Looking at the code, the origin of the error is:
        InitFonts();         if (loadableFonts) {             SetFontPath(0, 0, (unsigned char *)defaultFontPath, &error);         } else {             if (SetDefaultFontPath(defaultFontPath) != Success)                 ErrorF("failed to set default font path '%s'",                         defaultFontPath);         }         if (!SetDefaultFont(defaultTextFont))             FatalError("could not open default font '%s'", defaultTextFont); 
SetDefaultFont() is failing. Looking at that function (text below from IRC channel):
[19:57] <devsk> SetDefaultFont(char *defaultfontname)[19:57] <devsk> {[19:57] <devsk>     int         err;[19:57] <devsk>     FontPtr     pf;[19:57] <devsk>     XID         fid;[19:57] <devsk>     fid = FakeClientID(0);[19:57] <devsk>     err = OpenFont(serverClient, fid, FontLoadAll | FontOpenSync,[19:57] <devsk>                    (unsigned) strlen(defaultfontname), defaultfontname);[19:57] <devsk>     if (err != Success)[19:57] <devsk>         return FALSE;[19:57] <devsk>     pf = (FontPtr) LookupIDByType(fid, RT_FONT);[19:57] <devsk>     if (pf == (FontPtr) NULL)[19:57] <devsk>         return FALSE;[19:57] <devsk>     defaultFont = pf;[19:57] <devsk>     return TRUE;[19:57] <devsk> I have a feeling that LookupIDByType() is the one failing[19:58] <devsk> OpenFont() has error paths for malloc failures and none of those looked like plausible[19:58] <devsk> LookupIDByType() was obsoleted quite a while ago in xorg code[19:59] <devsk> nx-X11 of course is hanging onto old code[19:59] <devsk> is it possible that there is some interaction there with newer libXfont which is making that function fail now[20:00] <devsk> unfortunately for me, its not possible to go back to libXfont-1.4. There is a bunch of crap which needs to be downgraded as well. And dependency hell breaks loose if I try that[20:00] <devsk> above snippet is in ./programs/Xserver/dix/dixfonts.c
I did this experiment for localhost connection to avoid differences in client and server packages (which is not the case anyway because for me both client and remote server are Gentoo ~amd64 updated systems).
Anybody got any ideas of why this is happening? Is it really about the newer fontsproto and libXfont not being compatible with nx-libs?
Thanks,devsk