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: tkinter: "alloc: invalid block:" after askopenfilename
Type: crash Stage:
Components: Tkinter, Windows Versions: Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Todd Goldfinger, lccat, mkiever, paul.moore, serhiy.storchaka, steve.dower, terry.reedy, tim.golden, tomnor, zach.ware
Priority: normal Keywords:

Created on 2014-11-06 23:24 by lccat, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
tktest.py lccat, 2014-11-06 23:24 script for reproducing the bug
crash.py Todd Goldfinger, 2017-03-02 00:11 Run to reproduce crash
Messages (11)
msg230768 - (view) Author: (lccat) Date: 2014-11-06 23:24
After running the Tkinter file dialog ( tkinter.filedialog.askopenfilename() ), and closing the tkinter window the following error message is displayed:
alloc: invalid block: 0xb035e0: b0 0
To reproduce see the attached python script "tktest". This does not stop the program as far as i can see.  Also happens for the directory selector.
Platform is linux.
msg230771 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-11-07 08:38
Unfortunately I can't reproduce this bug (Python 3.4.0, Linux). When close the main window the output is:

Traceback (most recent call last):
  File "tktest.py", line 6, in <module>
    filename = tkinter.filedialog.askopenfilename()
  File "/usr/lib/python3.4/tkinter/filedialog.py", line 375, in askopenfilename
    return Open(**options).show()
  File "/usr/lib/python3.4/tkinter/commondialog.py", line 48, in show
    s = w.tk.call(self.command, *w._options(self.options))
_tkinter.TclError: can't invoke "grab" command: application has been destroyed
msg230791 - (view) Author: (lccat) Date: 2014-11-07 11:20
Your output is different because you did not close the file dialog by selecting something and the pressing OK, or pressing cancel before destroying the main window. This is also the case here:
Traceback (most recent call last):
  File "tktest.py", line 6, in <module>
    filename = tkinter.filedialog.askopenfilename()
  File "/usr/lib/python3.4/tkinter/filedialog.py", line 375, in askopenfilename
    return Open(**options).show()
  File "/usr/lib/python3.4/tkinter/commondialog.py", line 48, in show
    s = w.tk.call(self.command, *w._options(self.options))
_tkinter.TclError: can't invoke "grab" command: application has been destroyed
alloc: invalid block: 0x1d2cda0: a0 1
zsh: abort      python tktest.py

However, only the last two lines are relevant here, which you could not reproduce.
msg230795 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-11-07 11:49
When first close the file dialog (by pressing either Open, or Cancel, or close window button, or Alt-F4 keystroke), I don't see any output at all.

What Tk version (tkinter.TkVersion) is used? What Linux distribution name and version are?
msg230798 - (view) Author: (lccat) Date: 2014-11-07 12:03
>>print(TkVersion)
8.6
Tk version in package manager:
python-pmw 2.0.0-2
Distribution:
arch linux, kernel 3.17.2-1-ARCH
msg246198 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2015-07-03 17:46
Tomas Nordin reported on #24524 (will close as dup) that a similar script crashes python 2.7.9 on Linux debian.
msg246223 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2015-07-03 21:27
On Windows 7, no problem on either 2.7.10 or 3.5.0b2 (running from Command Prompt so would see message is there were one).
msg288780 - (view) Author: Todd Goldfinger (Todd Goldfinger) Date: 2017-03-02 00:11
This crashes reliably on Win10 with the same error message.  Place cursor after the 2 in the top spin box.  Type 0.

I have the following files in Anaconda3/tcl: tcl86t.lib, tcl86tg.lib, tclstub86.lib, tk86t.lib, tk86tg.lib, tkstub86.lib.


Python 3.6.0 |Anaconda 4.3.0 (64-bit)| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
msg288824 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-03-02 19:39
Thanks Todd.  I ran crash.py on Win10 64 bit, stock PSF 3.6.0 (no anaconda).  Put cursor after 2 and hit '0'.  Same error, different numbers.
alloc: invalid block: 000002C8928640D0: 40 93
Followed by Windows' "Python has stopped working" box.

Cursor after the '6' in second spinbox, hit 0, nothing happens.  I could not get rid of 6 to type in something new.  Not sure if this is normal or something about particular code.

Cursor before the '2': '0's can be inserted, nothing else.  After multiple insert and delete and arrow presses, got error when closing.
msg288827 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-02 19:56
I think issue27405 could help to make a pure Tcl reproducer. If the same error happen with Tcl version, this is not Python bug.
msg288830 - (view) Author: Todd Goldfinger (Todd Goldfinger) Date: 2017-03-02 20:32
>> cursor after the '6' follows by '0'

The max is 21.  See 'to' parameter.  I don't know if my code is correct, but it seems to work more or less.  Obviously the crash is an issue with tk or Python.
History
Date User Action Args
2022-04-11 14:58:09adminsetgithub: 66999
2017-07-14 14:19:37mkieversetnosy: + mkiever
2017-03-02 20:32:51Todd Goldfingersetmessages: + msg288830
2017-03-02 19:56:07serhiy.storchakasetmessages: + msg288827
2017-03-02 19:39:40terry.reedysetmessages: + msg288824
2017-03-02 00:11:14Todd Goldfingersetfiles: + crash.py
versions: + Python 3.6, - Python 2.7, Python 3.4
nosy: + paul.moore, tim.golden, Todd Goldfinger, zach.ware, steve.dower

messages: + msg288780

components: + Windows
2015-07-04 02:49:41serhiy.storchakasettype: enhancement -> crash
2015-07-03 22:43:52Roch Guillotsettype: behavior -> enhancement
2015-07-03 21:27:19terry.reedysetmessages: + msg246223
2015-07-03 18:14:43zach.waresetnosy: + tomnor
2015-07-03 18:14:27zach.warelinkissue24524 superseder
2015-07-03 17:46:02terry.reedysetnosy: + terry.reedy

messages: + msg246198
versions: + Python 2.7
2014-11-07 12:03:08lccatsetmessages: + msg230798
2014-11-07 11:49:57serhiy.storchakasetmessages: + msg230795
2014-11-07 11:20:58lccatsetmessages: + msg230791
2014-11-07 08:38:30serhiy.storchakasettype: behavior

messages: + msg230771
nosy: + serhiy.storchaka
2014-11-06 23:24:06lccatcreate