python / cpython

The Python programming language
https://www.python.org
Other
63.1k stars 30.22k forks source link

tkinter: "alloc: invalid block:" after askopenfilename #66999

Open 3526e307-f412-4420-93cf-8a03cc5b3850 opened 9 years ago

3526e307-f412-4420-93cf-8a03cc5b3850 commented 9 years ago
BPO 22810
Nosy @terryjreedy, @pfmoore, @mkiever, @tjguk, @zware, @serhiy-storchaka, @zooba
Files
  • tktest.py: script for reproducing the bug
  • crash.py: Run to reproduce crash
  • 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: ```python assignee = None closed_at = None created_at = labels = ['expert-tkinter', 'OS-windows', 'type-crash'] title = 'tkinter: "alloc: invalid block:" after askopenfilename' updated_at = user = 'https://bugs.python.org/lccat' ``` bugs.python.org fields: ```python activity = actor = 'mkiever' assignee = 'none' closed = False closed_date = None closer = None components = ['Tkinter', 'Windows'] creation = creator = 'lccat' dependencies = [] files = ['37142', '46683'] hgrepos = [] issue_num = 22810 keywords = [] message_count = 11.0 messages = ['230768', '230771', '230791', '230795', '230798', '246198', '246223', '288780', '288824', '288827', '288830'] nosy_count = 10.0 nosy_names = ['terry.reedy', 'paul.moore', 'mkiever', 'tim.golden', 'zach.ware', 'serhiy.storchaka', 'steve.dower', 'lccat', 'tomnor', 'Todd Goldfinger'] pr_nums = [] priority = 'normal' resolution = None stage = None status = 'open' superseder = None type = 'crash' url = 'https://bugs.python.org/issue22810' versions = ['Python 3.6'] ```

    3526e307-f412-4420-93cf-8a03cc5b3850 commented 9 years ago

    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.

    serhiy-storchaka commented 9 years ago

    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
    3526e307-f412-4420-93cf-8a03cc5b3850 commented 9 years ago
    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.

    serhiy-storchaka commented 9 years ago

    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?

    3526e307-f412-4420-93cf-8a03cc5b3850 commented 9 years ago

    >print(TkVersion) 8.6 Tk version in package manager: python-pmw 2.0.0-2 Distribution: arch linux, kernel 3.17.2-1-ARCH

    terryjreedy commented 9 years ago

    Tomas Nordin reported on bpo-24524 (will close as dup) that a similar script crashes python 2.7.9 on Linux debian.

    terryjreedy commented 9 years ago

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

    78e97413-f505-4178-8790-1adb61d49fa0 commented 7 years ago

    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.

    terryjreedy commented 7 years ago

    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.

    serhiy-storchaka commented 7 years ago

    I think bpo-27405 could help to make a pure Tcl reproducer. If the same error happen with Tcl version, this is not Python bug.

    78e97413-f505-4178-8790-1adb61d49fa0 commented 7 years ago

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