legionus / kbd

Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/legion/kbd.git
https://kbd-project.org
Other
84 stars 41 forks source link

Crash when setting a font larger than 32x32 #109

Closed oldherl closed 7 months ago

oldherl commented 8 months ago

I'm trying the new feature of setting a font larger than 32x32. Specifically, I am trying "setfont ter-132n -d" which sets a doubled 32x16 font, on archiso. It coredumped. image

legionus commented 8 months ago

The ter-132n is not a part of the kbd. Please, attach it or give me a link.

oldherl commented 8 months ago

ter-132n.psf.gz

It is a file from this Arch Linux package : https://archlinux.org/packages/extra/any/terminus-font/

oldherl commented 8 months ago

It also crashes when using the solar24x32 font:

# setfont -d solar24x32
Fatal glibc error: malloc.c:2594 (sysmalloc): assertion failed: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)
Aborted (core dumped)

image

legionus commented 8 months ago

I see what you're talking about. I pushed a fix for this. Try it.

oldherl commented 7 months ago

Thank you. However it still doesn't work.

# setfont solar24x32 -d
setfont: ERROR kdfontop.c:211 put_font_kdfontop: ioctl(KDFONTOP): Invalid argument

Does it require some kernel options to be enabled to use the fonts with height>32?

legionus commented 7 months ago

@oldherl I did some research. Yes, modern kernels support tall fonts, but the text console does not support such fonts. As far as I understand, you need to use a framebuffer to use large fonts.

oldherl commented 7 months ago

Yes, modern kernels support tall fonts, but the text console does not support such fonts. As far as I understand, you need to use a framebuffer to use large fonts.

Sad to hear about that. Do you have any reference links for it? Also, is it possible for setfont to detect whether it's in text console or not and print a better message?

legionus commented 7 months ago

Sad to hear about that. Do you have any reference links for it?

At the time when tall fonts were added to the kernel [1], fbdev was considered where support should be.

This change makes the fbcon driver consider vpitch appropriately, thus
making it able to load large fonts.

But later a check was added [2] that prohibits fonts larger than 32. The fbcon does not support such fonts [3]. The vgacon does not support such fonts [4]. As far as I see, other consoles do not support either.

Also, is it possible for setfont to detect whether it's in text console or not and print a better message?

Unfortunately, the kernel returns EINVAL if the console does not support tall fonts. The kernel returns the same error in a lot of other cases. Basically, the kernel returns EINVAL if it does not like the font based on some criteria. I don't yet know how to distinguish this error from other errors with EINVAL.

[1] https://github.com/torvalds/linux/commit/ffc1e089725e3f8a15ddfdce283db42f7d0fa147 [2] https://github.com/torvalds/linux/commit/2b09d5d364986f724f17001ccfe4126b9b43a0be [3] https://github.com/torvalds/linux/blob/master/drivers/video/fbdev/core/fbcon.c#L2488-L2489 [4] https://github.com/torvalds/linux/blob/master/drivers/video/console/vgacon.c#L1025-L1027

oldherl commented 7 months ago

Thank you very much for the explanation. I'm closing this issue now.