classification
Title: IDLE: make configdialog font page survive font failures
Type: behavior Stage: needs patch
Components: Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: epaine, terry.reedy
Priority: normal Keywords:

Created on 2021-09-04 21:16 by terry.reedy, last changed 2021-09-09 16:11 by epaine.

Messages (8)
msg401062 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-09-04 21:16
There were reports on a previous issue that attempting to display some characters from some linux fonts in some distributions resulted in crashing Python.  The crash reports mentioned XWindows errors about particular characters being too complex or something.  I did not open an issue for this because it seemed beyond the ability of tkinter/IDLE to predict and handle.

https://stackoverflow.com/questions/68996159/idle-settings-window-wont-appear reported that requesting the IDLE settings window resulting in IDLE hanging.  The user used my print debug suggestion to determine that the problem was in configdialog.py at
    self.fontpage = FontPage(note, self.highpage)

The user first thought the issue was with a chess font, and then determined that the problem font was the phaistos font from https://ctan.org/pkg/phaistos?lang=en.  The font has the symbols from the Cretan Linear A script on the Disk of Phaistos. This issue is about

1. Try to reproduce the issue by downloading and installing Phaistos.otf (right click on the file and click Install).

2. If successful, trace the problem to a specific line within the FontPage class.

3. Determine whether Python code can prevent the hang or if it is completely in other code.  (Either way, perhaps report to tcl/tk.)

... To remove, "open Control Panel -> Fonts then locate and select Phaistos Regular font then proceed with clicking Delete button."

I did not select 'test needed' because we cannot routinely install new fonts and I am not sure of how to do an automated test if we could.
However, I would add a note as to how to do a manual test.

font.otf = OpenTypeFont, used on Windows, Linux, macOS.
https://fileinfo.com/extension/otf
It might be good test on other systems after Windows.
msg401139 - (view) Author: E. Paine (epaine) * Date: 2021-09-06 15:08
FTR, the issue mentioned is issue42225.

msg380227 still applies for me (with Tk 8.6.11), with segfaults when I try to preview the font. For some reason, however, the segfault appears to be when we're closing the options window:

Python 3.9.6 (default, Jun 30 2021, 10:22:16) 
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import faulthandler
>>> faulthandler.enable()
>>> import idlelib.idle
Fatal Python error: Segmentation fault

Current thread 0x00007f0ca44c7740 (most recent call first):
  File "/usr/lib/python3.9/tkinter/__init__.py", line 2580 in destroy
  File "/usr/lib/python3.9/tkinter/__init__.py", line 2579 in destroy
  File "/usr/lib/python3.9/tkinter/__init__.py", line 2579 in destroy
  File "/usr/lib/python3.9/tkinter/__init__.py", line 2579 in destroy
  File "/usr/lib/python3.9/tkinter/__init__.py", line 2579 in destroy
  File "/usr/lib/python3.9/tkinter/__init__.py", line 2579 in destroy
  File "/usr/lib/python3.9/tkinter/__init__.py", line 2579 in destroy
  File "/usr/lib/python3.9/idlelib/configdialog.py", line 199 in destroy
  File "/usr/lib/python3.9/idlelib/configdialog.py", line 177 in ok
  File "/usr/lib/python3.9/tkinter/__init__.py", line 1892 in __call__
  File "/usr/lib/python3.9/tkinter/__init__.py", line 696 in wait_window
  File "/usr/lib/python3.9/idlelib/configdialog.py", line 94 in __init__
  File "/usr/lib/python3.9/idlelib/editor.py", line 583 in config_dialog
  File "/usr/lib/python3.9/tkinter/__init__.py", line 1892 in __call__
  File "/usr/lib/python3.9/tkinter/__init__.py", line 1858 in event_generate
  File "/usr/lib/python3.9/idlelib/editor.py", line 1185 in command
  File "/usr/lib/python3.9/tkinter/__init__.py", line 1892 in __call__
  File "/usr/lib/python3.9/tkinter/__init__.py", line 1429 in mainloop
  File "/usr/lib/python3.9/idlelib/pyshell.py", line 1572 in main
  File "/usr/lib/python3.9/idlelib/idle.py", line 14 in <module>
  File "<frozen importlib._bootstrap>", line 228 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 850 in exec_module
  File "<frozen importlib._bootstrap>", line 680 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 986 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1007 in _find_and_load
  File "<stdin>", line 1 in <module>
fish: Job 1, 'python' terminated by signal SIGSEGV (Address boundary error)

I do not experience any problems loading the IDLE preferences page. I will look into whether I can reproduce the problem described on Windows.
msg401140 - (view) Author: E. Paine (epaine) * Date: 2021-09-06 15:18
Apologies, my previous message was not clear. When the segfault occurs is not consistent and sometimes occurs when previewing the font (as reported in the linked message) but more often when clicking the "ok" button (for which the faulthandler details are included).
msg401176 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-09-06 19:30
Thank you for finding what I could not.

Your previous message, referenced above, reporting a problem that remains in 8.6.11 on linux, was ...

"For me, this is not limited to special characters. Trying to load anything in Tk using the 'JoyPixels' font crashes (sometimes it does load but all characters are very random - most are whitespace - and it crashes again after a call to `fc-cache`). IDLE crashes when trying to preview the font.

I believe this is what is being experienced on https://askubuntu.com/questions/1236488/x-error-of-failed-request-badlength-poly-request-too-large-or-internal-xlib-le because they are not using any special characters yet are reporting the same problem."

JoyPixels is an emoji font.  There are emoji in the BMP, but not in IDLE's initial font sample.  Did you add some, or did problems occur without displaying any emoji?
---

I presume that the Phaistos 'font' has glyphs for the unicode phaistos block in the first astral plane, U+101D0..101FD.
https://en.wikipedia.org/wiki/Phaistos_Disc_(Unicode_block)

If they include one of those characters in the font name displayed in the font list (ugh), then a problem is understandable, and the fix would be to filter astral chars (and possibly more) out of font names.  But I won't assume this.

Please try the experiments I outlined if you are so inclined.
msg401177 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-09-06 19:32
If nothing else, I should amend the doc note about font problems to include Windows if we verify the report.
msg401179 - (view) Author: E. Paine (epaine) * Date: 2021-09-06 19:48
> did problems occur without displaying any emoji

I was using an unmodified version of IDLE.

> If they include one of those characters in the font name displayed in the font list

This is not the case. It is listed simply as "Phaistos", when calling `tkinter.font.families()`.

> if we verify the report

Report verified. Behaviour is exactly as described, hanging when trying to load the "Configure IDLE" window. I will look into exactly which line is the problem soon.
msg401180 - (view) Author: E. Paine (epaine) * Date: 2021-09-06 20:11
IDLE is hanging on Lib/idlelib/configdialog.py:94 (`self.wait_window()`). Commenting this does not solve the problem: I think it's in the Tk event loop somewhere, since my debugger shows the Python callback completing successfully. This still doesn't explain the behaviour, however, so I'll need to spend a bit more time tracking it down.
msg401492 - (view) Author: E. Paine (epaine) * Date: 2021-09-09 16:11
It turns out the problem is a combination of the font and IDLE preview content. With the phaistos font installed, inserting the content of the "Devanagari, Tamil" or "East Asian" sections into a Tk text widget causes it to freeze. For example, the following will fail:

pack [text .t]
.t insert end \u0966

The reason for this still confuses me, since Tk would never default (I believe) to trying to use phaistos font (and therefore it's installation should not affect this). I will report it to the Tk team.
History
Date User Action Args
2021-09-09 16:11:53epainesetmessages: + msg401492
2021-09-06 20:11:38epainesetmessages: + msg401180
2021-09-06 19:48:49epainesetmessages: + msg401179
2021-09-06 19:32:11terry.reedysetmessages: + msg401177
2021-09-06 19:30:41terry.reedysetmessages: + msg401176
2021-09-06 15:18:22epainesetmessages: + msg401140
2021-09-06 15:08:24epainesetnosy: + epaine
messages: + msg401139
2021-09-04 21:16:59terry.reedycreate