Bug 281751

Summary: python crashes when sending an empty string to some Tkinter widgets
Product: [Fedora] Fedora Reporter: Stephen P. Schaefer <sschaefer>
Component: pythonAssignee: James Antill <james.antill>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: medium    
Version: 7CC: cummings, katzj, s.adam, tibbs, wtogami
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: 2.5-14.fc7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-10-29 15:03:20 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 235704, 312701    

Description Stephen P. Schaefer 2007-09-06 21:31:42 EDT
Description of problem:

Python exits with the following error:

python: ./Modules/_tkinter.c:941: AsObj: Assertion `size < size *
sizeof(Tcl_UniChar)' failed.
Aborted

Version-Release number of selected component (if applicable):

python-2.5-12.fc7
tkinter-2.5-12.fc7

How reproducible:

Always.

Steps to Reproduce:
1. Put the following script in t.py:
# -*- coding: utf-8 -*-
import sys, Tkinter, unicodedata
reload(sys)                              # restore module sys from disk
sys.setdefaultencoding('utf-8')    # or whatever codec you need
del sys.setdefaultencoding               # ensure against later accidents
Tkinter.Button(text=u"", command=sys.exit).pack( )
Tkinter.mainloop( )

2. run the program as: python t.py
  
Actual results:

python: ./Modules/_tkinter.c:941: AsObj: Assertion `size < size *
sizeof(Tcl_UniChar)' failed.
Aborted

Expected results:

A button window containing no text.

Additional info:
Comment 1 Stephen P. Schaefer 2007-09-06 21:35:49 EDT
The script contains some extra cruft.  This simplification also generates the error:

import sys, Tkinter
Tkinter.Button(text=u"", command=sys.exit).pack( )
Tkinter.mainloop( )
Comment 2 Stewart Adam 2007-10-07 18:02:55 EDT
I can confirm this with python/tkinter tkinter-2.5.1-11.fc8.

Is this problem easy to fix? It's preventing pysol (bug 312701) from running
properly.
Comment 3 Stewart Adam 2007-10-07 18:05:04 EDT
I forgot to mention, this bug is not present when manually compiling Python:
http://sourceforge.net/forum/forum.php?thread_id=1759959&forum_id=503709

Probably something we are passing to %configure or a patch is introducing the bug.
Comment 4 Stephen P. Schaefer 2007-10-18 16:44:41 EDT
The bug is present in multiple other widgets.  For instance,

import sys, Tkinter
Tkinter.Text(text=u"").pack( )
Tkinter.mainloop( )
Comment 5 Stephen P. Schaefer 2007-10-18 19:33:15 EDT
Here's a patch, which I've also supplied to bugs.python.org:

--- Python-2.5-fc7/Modules/_tkinter.c   2006-08-11 22:33:36.000000000 -0400
+++ Python-2.5/Modules/_tkinter.c       2007-10-18 18:44:40.000000000 -0400
@@ -938,7 +938,7 @@
 #if defined(Py_UNICODE_WIDE) && TCL_UTF_MAX == 3
                Tcl_UniChar *outbuf;
                Py_ssize_t i;
-               assert(size < size * sizeof(Tcl_UniChar));
+               assert(size == 0 || size < size * sizeof(Tcl_UniChar));
                outbuf = (Tcl_UniChar*)ckalloc(size * sizeof(Tcl_UniChar));
                if (!outbuf) {
                        PyErr_NoMemory();
Comment 6 James Antill 2007-10-19 12:15:09 EDT
 This should now be fixed, please test.
Comment 7 Jason Tibbitts 2007-10-19 16:19:19 EDT
I didn't see anything in bodhi about this so I pulled the packages from koji
(http://koji.fedoraproject.org/koji/buildinfo?buildID=21649) and update; pysol
at least works without problems now.

Could this fix please make it into F8?  There may still be time to slide it in
before the absolute freeze.
Comment 8 Jason Tibbitts 2007-10-21 14:25:02 EDT
It seems that it's just not that easy to find pending updates in bodhi because
there are a bunch of hits on python and the result list is neither sorted nor
sortable.  The update is at
https://admin.fedoraproject.org/updates/F7/pending/python-2.5-14.fc7
I've commented there.
Comment 9 Stephen P. Schaefer 2007-10-22 11:17:52 EDT
I didn't know where to find the changed version until comment #7.  The URL in
comment #8 refused my credentials.  Now that I've installed *-2.5-14.fc7*,
things are working fine for me.  If there is a specified testing regimen I
should follow, please give a URL for that.  Thanks.
Comment 10 Warren Togami 2007-10-22 11:50:50 EDT
We need this fix in F8 as well.
Comment 11 Fedora Update System 2007-10-24 03:17:38 EDT
python-2.5-14.fc7 has been pushed to the Fedora 7 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update python'
Comment 12 Kevin J. Cummings 2007-10-24 17:35:42 EDT
# yum --enablerepo=updates-testing update python
google                    100% |=========================|  951 B    00:00     
fedora                    100% |=========================| 2.1 kB    00:00     
updates-testing           100% |=========================| 2.3 kB    00:00     
primary.sqlite.bz2        100% |=========================| 141 kB    00:00     
updates                   100% |=========================| 2.3 kB    00:00     
adobe-linux-i386          100% |=========================|  951 B    00:00     
Setting up Update Process
Could not find update match for python
No Packages marked for Update
Comment 13 Fedora Update System 2007-10-29 15:03:15 EDT
python-2.5-14.fc7 has been pushed to the Fedora 7 stable repository.  If problems still persist, please make note of it in this bug report.