_     _             
                        _ __ | |__ | | ___   __ _ 
                       | '_ \| '_ \| |/ _ \ / _` |
                       | |_) | | | | | (_) | (_| |
                       | .__/|_| |_|_|\___/ \__, |
                       |_|    ...2019-03-01 |___/ 

A debug session: xmoto

tldr; I Solved it by reinstalling the dejavu font packages and remove the ~/.local/share/xmoto ~/.config/xmoto ~/.cache/xmoto directories. So, I wanted to play xmoto, and i did apt-get install xmoto.. Game didn't start, in bash:
$ xmoto fatal exception : FontManager: Couldn't open Textures/Fonts/DejaVuSans.ttf
Alright, I thought maybe my system was outdated (I was sleepy!) so I did apt-get update && apt-get ugprade and rebooted for good measure. Now the game did: fatal exception : Unable to get xmDb version: Which is totally different than the first error message. I thought this was the next problem in line, the texture/font stuff being solved by the update and reboot. So I digged into it. Online I only found xmoto breaking from updating, resulting in some xmoto- generated files in the users directory being an older, incompatible version. After doing xmoto -v i found the three directories mentioned in tldr. I removed them all and ran xmoto again: Lo and behold! I got the original message about Fonts/DejavuSans.ttf !!! Hmm, okay. So I removed the directories again, and ran this sh:
strace xmoto &> log.txt ato # I searched the log for mentions of dejavu: grep -i dejavu log.txt openat(AT_FDCWD, "/home/dusted/.local/share/xmoto/Textures/Fonts/DejaVuSans.ttf", O_RDONLY) = -1 ENOENT (No such file or directory) openat(AT_FDCWD, "/usr/share/games/xmoto/Textures/Fonts/DejaVuSans.ttf", O_RDONLY) = -1 ELOOP (Too many levels of symbolic links) openat(AT_FDCWD, "/home/dusted/.local/share/xmoto/Textures/Fonts/DejaVuSans.ttf", O_RDONLY) = -1 ENOENT (No such file or directory) openat(AT_FDCWD, "/usr/share/games/xmoto/Textures/Fonts/DejaVuSans.ttf", O_RDONLY) = -1 ELOOP (Too many levels of symbolic links) openat(AT_FDCWD, "Textures/Fonts/DejaVuSans.ttf", O_RDONLY) = -1 ENOENT (No such file or directory) write(1, "fatal exception : FontManager: C"..., 75fatal exception : FontManager: Couldn't open Textures/Fonts/DejaVuSans.ttf
Okay, so first attempt to hack it sh:
mkdir -p ~/.local/share/xmoto/Textures/Fonts cp /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf ~/.local/share/xmoto/Textures/Fonts Too many levels of symbolic links!
Aha! ls -l /usr/share/fonts/truetype/dejavu/ revealed circular symlinks! One of the implicated files were the one xmoto wanted.. I then reinstalled dejavu packages I had installed sh:
apt-get install --reinstall ttf-dejavu-core fonts-dejavu-extra
Which fixed it! I do recall doing some nasty hack on dejvu some time ago which fixed whatever it was supposed to fix, but I guess the upgrade or something in the mean time messed with the font too.

Stupid failure modes in general

While I won't dispute that in the end, it was my fault that xmoto didn't run right away, the way it failed, which is not unique to xmoto, caused the majority of grief when debugging it. See, the root-cause of the problem was the missing font, but after the first (failed) run, files had been created which were somehow ill-formed enough to cause the "fatal exception : Unable to get xmDb version:" error on every subsequent run, hiding the original error. I didn't dig into the xmoto code, but I speculate that the program started building some database or other file while loading the textures. When the texturemanager failed, it exited with the files in such a state that upon starting the program again, it would fail even earlier. I'm guessing that the program does something like if no_database -> create database load textures -> put stuff into database? close database? If running this, on the first run, there is no database, so the version check won't fail, but the texture stuff will fail, causing corrupt files to exist, so that on the next runs, it never reaches the texture stuff, hiding the problem for posterity.

Not a big critique

I spent a lot of words on this, not because xmoto is a bad program by any measure, or because it's a terrible problem (I have a special talent for hitting every edge-case in every system all the time), but because it's an interesting example of emergent complexity in my opinion. In large systems, there will be orders of magnitude more complexity and orders of magniture more emergent complexity and in such systems, I ask everyone to try to dump down their error behaviour. Try actually executing your error handling paths, twice, and ensure that your system will behave in a consistent way, and provide somewhat understandable error messages. An improved version of the xmoto texture failure could be: fatal exception : FontManager: Failed to find DejaVuSans.ttf in /home/dusted/.local/share/xmoto/Textures/Fonts/ /usr/share/games/xmoto/Textures/Fonts/ /home/dusted/.local/share/xmoto/Textures/Fonts/ /usr/share/games/xmoto/Textures/Fonts/ ./Textures/Fonts/ Now, THAT would have allowed anyone to quickly check for those files, there they would have found a symlink to the file in /usr/share/fonts/, and in this situation, found that the file was a circular reference. The next improvement would be that no exception during startup would leave malformed files on the system, since that'll hide the actual failures on further runs.


That's a long rant for nothing. I'm not hating on xmoto here, it's an awesome game, and I don't even think this would be worth fixing, as it's a pretty niche edge-case that practically nobody will experience, which is evident by the fact that I didn't find a single description of it online. So let this be the first.


Thumbs up to xmoto developers, keep being awesome! :)