This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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

Created on 2021-09-04 21:16 by terry.reedy, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (15)
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.
msg402066 - (view) Author: E. Paine (epaine) * Date: 2021-09-17 16:41
https://core.tcl-lang.org/tk/tktview/0338867c742


IMO this should be closed as third-party, since there is very little we can / should do (yes we could remove the offending characters from the preview if the user has the font installed, but this is a lot of extra code for a very rare issue).
msg403346 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-10-07 02:22
A similar report, https://stackoverflow.com/questions/69466716/python-3-10-idle-does-not-respond-everytime-i-hit-configure-idle-from-options
but with FiraCode font https://github.com/tonsky/FiraCode.  The compatibility list includes IDLE as 'does not work' along with some other editors.
msg403395 - (view) Author: E. Paine (epaine) * Date: 2021-10-07 11:48
I am unable to reproduce on either Python 3.9.6 (Tk 8.6.9) or 3.10.0 (Tk 8.6.10).
msg403422 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-10-07 14:57
Thanks.  Did the FiraCode font work for you or merely not work without crashing?
msg403465 - (view) Author: E. Paine (epaine) * Date: 2021-10-08 09:38
> Did the FiraCode font work for you or merely not work without crashing?

It worked fine (other than a few missing features such as context-aware punctuation).

The steps I did to test were:

- Load IDLE
- Enter config dialog
- Set IDLE to use Fira Code font
- Use 'OK' button to exit config dialog
- Close IDLE
- Reload IDLE
- Enter config dialog
- Revert font
msg403546 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-10-09 18:30
Bizarre.  The SO OP just reported that deleting FiraCode fixed *his* 3.10 problem.  There must be some unobvious difference in systems.
msg406415 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-11-16 16:38
This has been (supposedly) fixed in tcl/tk 8.6.12, included with all our Windows installers starting with 3.9.9.

Thank you for investigating reporting to tcl/tk.  Bugfix list at
https://github.com/tcltk/tk/blob/8baf7d337ca0aab7fafb0e670927ab2c0200e80a/changes#L7869
credits you along with 'vogel': "2021-09-21 (bug)[033886] Win: hang in font loading (e-paine,vogel)"
https://sourceforge.net/p/tcl/mailman/message/37380142/
specifically says fixes include "" - Windows loading of the Phaistos font.".
History
Date User Action Args
2022-04-11 14:59:49adminsetgithub: 89266
2021-11-16 16:38:55terry.reedysetstatus: open -> closed
resolution: third party
messages: + msg406415

stage: needs patch -> resolved
2021-10-09 18:30:34terry.reedysetmessages: + msg403546
2021-10-08 09:38:16epainesetmessages: + msg403465
2021-10-07 14:57:03terry.reedysetmessages: + msg403422
2021-10-07 11:48:44epainesetmessages: + msg403395
2021-10-07 02:22:24terry.reedysetassignee: terry.reedy
messages: + msg403346
components: + IDLE
2021-09-17 16:41:58epainesetmessages: + msg402066
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