tk/wish segmentation fault when handling a specific font

Bug #1997762 reported by Frans van der Have
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tk8.6 (Ubuntu)
New
Undecided
Unassigned

Bug Description

I am working on a Tcl/Tk application. When I was iterating over all available font families on the system in order to find a font that best matches some desirable properties, I encountered a segmentation fault, which I did not expect. I simplified the situation to the attached script. The expected behavior is that the script prints the linespace size and width of the reference text for 20 font sizes expressed in pixels, then prints "Done" and closes without error. The font that causes the problem is "Noto Color Emoji" from Ubuntu package "fonts-noto-color-emoji".

On Ubuntu 18.04.6 LTS with Tcl/Tk 8.6.8 installed, it does not have a segfault, but there is an error in the X Window functionality used by Tk. The output is:
---------- 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 -----------------------

On Ubuntu 22.04.1 LTS, with Tcl/Tk 8.6.12 there is a segmentation fault:
---------- 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 -----------------------

Revision history for this message
Frans van der Have (fvanderhave) wrote :

The reproducing test script as text:
--------- 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 ------------

Revision history for this message
Frans van der Have (fvanderhave) wrote :
Revision history for this message
Frans van der Have (fvanderhave) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.