Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when setting a font larger than 32x32 #109

Closed
oldherl opened this issue Feb 3, 2024 · 9 comments
Closed

Crash when setting a font larger than 32x32 #109

oldherl opened this issue Feb 3, 2024 · 9 comments

Comments

@oldherl
Copy link

oldherl commented Feb 3, 2024

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
Copy link
Owner

legionus commented Feb 4, 2024

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

@oldherl
Copy link
Author

oldherl commented Feb 4, 2024

ter-132n.psf.gz

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

@oldherl
Copy link
Author

oldherl commented Feb 4, 2024

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 added a commit that referenced this issue Feb 5, 2024
The problem occurs if the font height becomes greater than 32 when
doubling. Another problem is that if the height is greater than 32 then
the vpitch value becomes incorrect and cannot be loaded into the kernel.

As a solution, we need to adjust vpitch before buffer allocation.

Link: #109
Co-developed-by: Oleg Bulatov <oleg@bulatov.me>
Signed-off-by: Alexey Gladkov <legion@kernel.org>
@legionus
Copy link
Owner

legionus commented Feb 5, 2024

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

@oldherl
Copy link
Author

oldherl commented Feb 6, 2024

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
Copy link
Owner

legionus commented Feb 8, 2024

@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
Copy link
Author

oldherl commented Feb 8, 2024

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
Copy link
Owner

legionus commented Feb 9, 2024

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] torvalds/linux@ffc1e08
[2] torvalds/linux@2b09d5d
[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
Copy link
Author

oldherl commented Feb 10, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants