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: Sudden crash displaying certain characters in tk widget
Type: crash Stage: resolved
Components: Tkinter Versions: Python 3.10
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Tkinter hangs or crashes when displaying astral chars
View: 42225
Assigned To: terry.reedy Nosy List: christian.heimes, serhiy.storchaka, terry.reedy, tetelevm
Priority: normal Keywords:

Created on 2021-03-28 15:26 by tetelevm, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (9)
msg389635 - (view) Author: Mikhail (tetelevm) * Date: 2021-03-28 15:26
Hi! I'm not sure if it's an IDLE, library, Xserver or font error, but either way, IDLE is behaving incorrectly. I have installed 3.8 and 3.9 versions, and on both it works, I do not know about the others, but I suspect that on the others, this error also occurs.

The error occurs in the following way: if you type any of the characters '\u270(5-f)' in IDLE, its work will stop unexpectedly. I suspect that for many other symbols there will be the same error, but so far noticed only on these. 

This is what the output to the terminal says:
```
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:  2131
  Current serial number in output stream:  2131
```

I think the error is somewhere in the system error handler or in the incorrect behavior of the fonts display (or both :) ), it would be more correct to catch the error and display it in the output, rather than suddenly terminate.

My system is Ubuntu 20.04, KDE 5.
msg389636 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-03-28 16:32
I cannot reproduce the issue on Fedora 33 with KDE 5 and libX11-1.6.12:

Python 3.9.2 (default, Feb 20 2021, 00:00:00) 
[GCC 10.2.1 20201125 (Red Hat 10.2.1-9)] on linux
Type "help", "copyright", "credits" or "license()" for more information.
>>> '\u2705'
'✅'
>>> '\u270f'
'✏'
msg389646 - (view) Author: Mikhail (tetelevm) * Date: 2021-03-28 20:06
I checked the behavior, and found out that it depends on the font. I have "Noto Sans Mono", and if I enter, for example, '\u2709', IDLE crashes. But if I put another font, for example 'Dejavu Mono', just a blank line is displayed. Also, if I output the characters to "dejavu" and then switch to "noto", the bug disappears until I restart IDLE.

P.S. I've played around, and crashes don't always happen when I change font, but, personally, it always happens when I open IDLE with "Noto Sans Mono" font. Also, if needed, I can check tomorrow on other laptops with other systems.
msg389647 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-03-28 20:19
Excellent investigation!

Idle automatically picked Dejavu Sans Mono as default font. I have also several fonts for e.g. unicode symbols and emojis installed. Noto Sans Mono CJK fonts are working fine, too. However when I select the Noto Emoji font in the font selector, Idle immediately crashes with a very similar Xlib error

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:  12760
  Current serial number in output stream:  12769
msg389659 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-03-29 06:21
This is actually a tk and tkinter issue rather than IDLE issue as such.  Python code can only catch Python exceptions, and I believe that the Xserver crash does not result in one.  These crashes were reported on a different issue and the conclusion there is that there is nothing we know to do.

IDLE uses the default tkFixedFont unless the user selects another one.  If tk selects a font that crashes, that is not IDLE's fault, or even tkinter's.  If there were a font that was always available on every *nix system and that never crashed for any unicode char, then IDLE could select that on *nix systems.  But I have no idea of such.  (Courier serves that purpose on Windows, and it is the tkFixedFont font on Windows.)

In the meanwhile, users can select a different font upon startup, which only uses ascii chars (if one starts with Shell and no editor).  Select Options => Configure IDLE.  Possible use the font sample box to try out the problematic chars but pasting or otherwise inserting.  If IDLE crashes, try again.  The resolution of this issue might be to say something more in the doc about this problem, as people seem to be using non-ascii more often, or maybe more ofter loading fonts that do not work.

Serhiy, can you say any more?  You know much more about tk/tkinter default font choices and Xserver font crashes than I do.
msg389660 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-03-29 06:32
Looks like a duplicate of issue42225. It happens with colored fonts. In any case it is a Tk issue and it should be fixed in the latest Tk bugfix release (8.6.11).
msg389664 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-03-29 07:11
Closing as a duplicate.  What's new here is that BMP chars can be affected also.

I opened #43652 to upgrade Windows installer to 8.6.11 (though not needed for this) but I guess Linux users have to bug their distributor or learn to upgrade themselves.
msg389666 - (view) Author: Mikhail (tetelevm) * Date: 2021-03-29 07:35
Yes, this is exactly the same problem as `issue42225`. I suspected it was a Tkinter problem, and also thought that Python might be under the hood catching C method call errors. 

But since you know about this problem, and in more detail than I have written here, this issue can be closed.

P.S. By the way, while I was doing my little investigation with fonts, here's another little bug I found :) 
When I start to write any word in IDLE and press Tab, the autocomplete box is shown (or auto-complete if the only mapping). But if I was doing something in "Configure IDLE" and pressed "Ok" to close the configure window, then pressing Tab just causes tab to appear at the cursor instead of auto-complete.

You probably know about it, but You know, I'm something of a developer myself, so it's better to report a bug than not report it.
msg389675 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-03-29 08:43
Thank you for reporting. While I may have had tab not work after the dialog, I had never connected the two.  Nor, AFAIK, was there an existing report. I verified, investigated more, and opened #43654.
History
Date User Action Args
2022-04-11 14:59:43adminsetgithub: 87813
2021-03-29 08:43:17terry.reedysetmessages: + msg389675
2021-03-29 07:35:39tetelevmsetmessages: + msg389666
2021-03-29 07:11:06terry.reedysetstatus: open -> closed
superseder: Tkinter hangs or crashes when displaying astral chars
messages: + msg389664

resolution: duplicate
stage: resolved
2021-03-29 06:32:13serhiy.storchakasetmessages: + msg389660
2021-03-29 06:21:17terry.reedysettype: crash
title: Sudden crash on print() of some characters -> Sudden crash displaying certain characters in tk widget
components: + Tkinter, - IDLE

nosy: + serhiy.storchaka
versions: + Python 3.10, - Python 3.8, Python 3.9
messages: + msg389659
2021-03-28 20:19:54christian.heimessetmessages: + msg389647
2021-03-28 20:06:40tetelevmsetmessages: + msg389646
2021-03-28 16:32:16christian.heimessetnosy: + christian.heimes
messages: + msg389636
2021-03-28 15:26:40tetelevmcreate