On an older computer running Linux (using vesafb, musl libc, busybox), Netsurf will occasionally segfault in low memory situations. When it does so, the last image stays visible on the display, and typing seems to do nothing, including trying to switch VT using Ctrl-Alt-Fx. I'd like to know why it does this, and how to fix it.

I can happily SSH into the machine and shut it down, and there doesn't seem to be anything in dmesg. This doesn't happen on a machine with an intel GPU, running Arch (systemd). The behavior is similar to that described at re-initialize the framebuffer when program crashes, and is also using SDL.

According to https://dvdhrm.wordpress.com/2013/08/24/how-vt-switching-works/, the kernel should be handling VT switching, so this behavior seems quite surprising to me.


This is caused by SDL setting the terminal mode to KD_GRAPHICS and input to K_MEDIUMRAW. KD_GRAPHICS causes the terminal to stop drawing to the display, while K_MEDIUMRAW causes the input to be passed as keycodes (not characters). By resetting both values to KD_TEXT and K_XLATE or K_UNICODE, the terminal can be (at least partially) restored.

I wrote (based on some existing code) a small program for restoring the console, which seems to work well: https://github.com/hobbitalastair/termfix

See also Best practice for hiding virtual console while rendering video to framebuffer and http://lct.sourceforge.net/lct/x60.html.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.