Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDLE: make configdialog font page survive font failures #89266

Closed
terryjreedy opened this issue Sep 4, 2021 · 15 comments
Closed

IDLE: make configdialog font page survive font failures #89266

terryjreedy opened this issue Sep 4, 2021 · 15 comments
Assignees
Labels
3.11 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@terryjreedy
Copy link
Member

BPO 45103
Nosy @terryjreedy, @E-Paine

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/terryjreedy'
closed_at = <Date 2021-11-16.16:38:55.697>
created_at = <Date 2021-09-04.21:16:59.833>
labels = ['expert-IDLE', 'type-bug', '3.11']
title = 'IDLE: make configdialog font page survive font failures'
updated_at = <Date 2021-11-16.16:38:55.696>
user = 'https://github.com/terryjreedy'

bugs.python.org fields:

activity = <Date 2021-11-16.16:38:55.696>
actor = 'terry.reedy'
assignee = 'terry.reedy'
closed = True
closed_date = <Date 2021-11-16.16:38:55.697>
closer = 'terry.reedy'
components = ['IDLE']
creation = <Date 2021-09-04.21:16:59.833>
creator = 'terry.reedy'
dependencies = []
files = []
hgrepos = []
issue_num = 45103
keywords = []
message_count = 15.0
messages = ['401062', '401139', '401140', '401176', '401177', '401179', '401180', '401492', '402066', '403346', '403395', '403422', '403465', '403546', '406415']
nosy_count = 2.0
nosy_names = ['terry.reedy', 'epaine']
pr_nums = []
priority = 'normal'
resolution = 'third party'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue45103'
versions = ['Python 3.11']

@terryjreedy
Copy link
Member Author

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.

@terryjreedy terryjreedy added 3.11 only security fixes type-bug An unexpected behavior, bug, or error labels Sep 4, 2021
@E-Paine
Copy link
Mannequin

E-Paine mannequin commented Sep 6, 2021

FTR, the issue mentioned is bpo-42225.

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.

@E-Paine
Copy link
Mannequin

E-Paine mannequin commented Sep 6, 2021

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).

@terryjreedy
Copy link
Member Author

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.

@terryjreedy
Copy link
Member Author

If nothing else, I should amend the doc note about font problems to include Windows if we verify the report.

@E-Paine
Copy link
Mannequin

E-Paine mannequin commented Sep 6, 2021

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.

@E-Paine
Copy link
Mannequin

E-Paine mannequin commented Sep 6, 2021

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.

@E-Paine
Copy link
Mannequin

E-Paine mannequin commented Sep 9, 2021

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.

@E-Paine
Copy link
Mannequin

E-Paine mannequin commented Sep 17, 2021

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).

@terryjreedy
Copy link
Member Author

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.

@terryjreedy terryjreedy self-assigned this Oct 7, 2021
@terryjreedy terryjreedy self-assigned this Oct 7, 2021
@E-Paine
Copy link
Mannequin

E-Paine mannequin commented Oct 7, 2021

I am unable to reproduce on either Python 3.9.6 (Tk 8.6.9) or 3.10.0 (Tk 8.6.10).

@terryjreedy
Copy link
Member Author

Thanks. Did the FiraCode font work for you or merely not work without crashing?

@E-Paine
Copy link
Mannequin

E-Paine mannequin commented Oct 8, 2021

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

@terryjreedy
Copy link
Member Author

Bizarre. The SO OP just reported that deleting FiraCode fixed *his* 3.10 problem. There must be some unobvious difference in systems.

@terryjreedy
Copy link
Member Author

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.".

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant