Ticket UUID: | ef14c053b2d6735e98dc8557613c4e87955713b | |||
Title: | segfault when handling a specific font | |||
Type: | Bug | Version: | 8.6.12 | |
Submitter: | SVIDevelopment | Created on: | 2022-11-24 16:20:30 | |
Subsystem: | 46. Unix Fonts | Assigned To: | nobody | |
Priority: | 5 Medium | Severity: | Minor | |
Status: | Closed | Last Modified: | 2022-11-24 16:41:00 | |
Resolution: | Duplicate | Closed By: | jan.nijtmans | |
Closed on: | 2022-11-24 16:41:00 | |||
Description: |
While working on an application that uses Tcl/Tk 8.6.11 built from source, I was iterating over the list of available font families. For each family, I wanted to obtain some measurements. For example, for different sizes, I want to have the line spacing and the width of a certain reference text string in order to find a suitable font that best matches some desirable values. When I was testing this on Ubuntu machines, I encountered an unexpected segfault while it was processing a font called "Noto Color Emoji". I simplified the script to the following wish script and executed it with the stock wish 8.6.8 on Ubuntu 18.04 LTS and wish 8.6.12 on Ubuntu 22.04 LTS. The expected output of the script is that it iterates through 20 sizes and prints a linespace and width value for each, prints "Done.", and exits without error, or perhaps prints an error message if I am doing something that is not supported. The script is this: --------- begin wish script ------------ #!/usr/bin/env wish set famName "Noto Color Emoji" set availList [font families] set weight "bold" set refText "The quick brown fox jumps over the lazy dog." if {$famName ni $availList} { puts "Font family $famName is not available on your system. " puts "If you are running Ubuntu, please install the package " puts "'fonts-noto-color-emoji'." return } puts "tcl patchlevel: [info patchlevel]" puts "tcl_platform:" foreach key [array names tcl_platform] { puts "$key: $tcl_platform($key)" } for {set pixSize -1} {$pixSize >= -20} {incr pixSize -1} { font create myTestFont -size $pixSize -family $famName -weight $weight set linespace [font metrics myTestFont -linespace] set width [font measure myTestFont $refText] font delete myTestFont puts "Size $pixSize linespace $linespace width $width." } puts "Done." --------- end wish script ------------ The output when run on Ubuntu 18.04 LTS with Tcl/Tk 8.6.8 prints an error that indicates something is wrong in the interaction between Tk and X Windows. There is no segfault in this case: ---------- begin Ubuntu 18.04 output ----------------------- tcl patchlevel: 8.6.8 tcl_platform: osVersion: 4.15.0-197-generic pointerSize: 8 byteOrder: littleEndian threaded: 1 machine: x86_64 platform: unix pathSeparator: : os: Linux engine: Tcl user: frans wordSize: 8 Size -1 linespace 1 width 30. Size -2 linespace 2 width 46. Size -3 linespace 3 width 74. Size -4 linespace 4 width 104. Size -5 linespace 6 width 130. Size -6 linespace 7 width 151. Size -7 linespace 8 width 185. Size -8 linespace 9 width 206. Size -9 linespace 11 width 222. Size -10 linespace 12 width 261. Size -11 linespace 13 width 285. Size -12 linespace 14 width 310. Size -13 linespace 16 width 335. Size -14 linespace 16 width 361. Size -15 linespace 17 width 386. Size -16 linespace 18 width 410. Size -17 linespace 20 width 438. Size -18 linespace 21 width 470. Size -19 linespace 22 width 496. Size -20 linespace 23 width 516. Done. X Error of failed request: BadLength (poly request too large or internal Xlib length error) Major opcode of failed request: 139 (RENDER) Minor opcode of failed request: 20 (RenderAddGlyphs) Serial number of failed request: 30 Current serial number in output stream: 795 ---------- end Ubuntu 18.04 output ----------------------- When the same script is run on Tcl/Tk 8.6.12 on Ubuntu 22.04 LTS, it segfaults after iterating through a few sizes: ---------- begin Ubuntu 22.04 output ----------------------- tcl patchlevel: 8.6.12 tcl_platform: osVersion: 5.15.0-52-generic pointerSize: 8 byteOrder: littleEndian threaded: 1 machine: x86_64 platform: unix pathSeparator: : os: Linux engine: Tcl user: frans wordSize: 8 Size -1 linespace 1 width 38. Size -2 linespace 2 width 54. Size -3 linespace 3 width 90. Segmentation fault (core dumped) ---------- end Ubuntu 22.04 output ----------------------- I submitted the problem to Ubuntu Launchpad as well https://bugs.launchpad.net/ubuntu/+source/tk8.6/+bug/1997762 in case there is something Ubuntu-specific in this bug, but I suspect it will reproduce on the upstream Tk as well provided that the font is available. | |||
User Comments: |
jan.nijtmans added on 2022-11-24 16:41:00:
Dup of [3767882e06] |
