Q: When does it occur?
A: When I connect to specific Wi-Fi. Apparently the transient hostname gets set to "unknown" + some random string.
~/w/a git:(master) ✗ hostnamectl
Static hostname: rok-laptop
Transient hostname: unknownc417fe03cb97
Icon name: computer-laptop
Q: What does it cause?
1. GNOME does sometimes crash. No logs anywhere, the graphical environment just crashes, dropping you to the virtual terminal. I am positive this is the cause of this, because this has happened over 100 times, everytime with that Wi-Fi.
2. Java starts reporting UnknownHostException.
java.net.UnknownHostException: unknownc417fe03cb97: unknownc417fe03cb97: unknown error
Q: Does anybody have any idea?
Yeah, changing the hostname is known to cause issues with X11.
You can set UseHostname=false in your networkd config to prevent that from happening.
Sadly, I have done that months ago, the sitiation is exactly the same:
# cat /etc/systemd/network/50-dhcp.network
Even if it worked, it should be by default set to false.
I have finally realised that match should be wl* not en*. Thanks. But anyways, I think this should be off by default, given the harsh consequences, therefore I will just leave this open.
That's a battle to be fought with systemd upstream.
Gentoo can provide more sensible default config files. X11 crashes are not OK.
As far as I can tell, the only way to configure networkd is via *.network files in /etc/systemd/network. Gentoo does not ship any network files by default, and it would be inappropriate to do so.
Anyway, I suspect your crashes are occurring due to entries in ~/.Xauthority which are tied to your hostname. I have not found any reasonable solution we could implement as a Linux distro.