Tk Source Code

View Ticket
Login
Ticket UUID: 9814507dcc307fe889208629b94132b1f5ed90de
Title: font measure \u4000 crashes on macOS with XQuartz
Type: Bug Version: core-8-6-branch
Submitter: fvogel Created on: 2023-12-30 16:15:17
Subsystem: 46. Unix Fonts Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-10-22 17:22:38
Resolution: Duplicate Closed By: serhiy.storchaka
    Closed on: 2026-10-08 13:15:15
Description:

On macOS with XQuartz, the following script crashes:

package require Tk
font measure {Courier -10} \u4000

The error message is:

X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  45 (X_OpenFont)
  Value in failed request:  0xa0000c
  Serial number of failed request:  124
  Current serial number in output stream:  125

For this reason test unixFont-8.4 crashes on macOS with XQuartz.

On macOS aqua there is no such problem.

User Comments: serhiy.storchaka added on 2026-10-08 13:15:15:

This is the same XQuartz bug as [36e379c01b] (XQuartz issue 216). Since [d2f53df7a8] (Tk 9.0.0, and 8.6.16), fonts are loaded with BadValue errors from X_OpenFont ignored, so the font is skipped instead of the program exiting.


chrstphrchvz added on 2024-01-03 03:25:48:

I think Tk is likely not causing this issue. There are reports of Monaco and other Apple system fonts font causing this error in other X11 programs: https://github.com/XQuartz/XQuartz/issues/216


fvogel added on 2024-01-01 18:13:24:

The BadValue error is triggered by the call to XLoadQueryFont here in GetScreenFont(). Value of buf in this call is "-misc-monaco-medium-r-normal--10-*-*-*-*-*-iso10646-1", which looks OK to me since the font is listed by xlsfonts:

bll-mac:~ fvogel$ DISPLAY=:0 xlsfonts |grep misc-monaco.*iso10646
-misc-monaco-medium-r-normal--0-0-0-0-p-0-iso10646-1

I don't understand what's wrong here. Documentation for XLoadQueryFont does not say that a BadValue error is possible.

A possible reference (with no solution): https://stackoverflow.com/questions/57078805/xloadqueryfont-fails-on-font-found-with-xlistfonts