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

tkinter goes into an infinite loop (pydoc.gui) #48085

Closed
HWJ mannequin opened this issue Sep 11, 2008 · 15 comments
Closed

tkinter goes into an infinite loop (pydoc.gui) #48085

HWJ mannequin opened this issue Sep 11, 2008 · 15 comments
Labels
extension-modules C modules in the Modules dir topic-tkinter type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@HWJ
Copy link
Mannequin

HWJ mannequin commented Sep 11, 2008

BPO 3835
Nosy @loewis, @asvetlov
Files
  • issue_3835.diff
  • issue_3835_2.diff
  • 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 = None
    closed_at = <Date 2012-03-14.16:50:16.795>
    created_at = <Date 2008-09-11.13:20:28.753>
    labels = ['extension-modules', 'expert-tkinter', 'type-crash']
    title = 'tkinter goes into an infinite loop (pydoc.gui)'
    updated_at = <Date 2012-03-14.16:50:16.793>
    user = 'https://bugs.python.org/HWJ'

    bugs.python.org fields:

    activity = <Date 2012-03-14.16:50:16.793>
    actor = 'asvetlov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-03-14.16:50:16.795>
    closer = 'asvetlov'
    components = ['Extension Modules', 'Tkinter']
    creation = <Date 2008-09-11.13:20:28.753>
    creator = 'HWJ'
    dependencies = []
    files = ['11510', '24825']
    hgrepos = []
    issue_num = 3835
    keywords = ['patch']
    message_count = 15.0
    messages = ['73021', '73237', '73259', '73265', '73302', '73303', '73304', '73324', '73332', '155640', '155664', '155665', '155763', '155764', '155765']
    nosy_count = 5.0
    nosy_names = ['loewis', 'gpolo', 'HWJ', 'asvetlov', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'rejected'
    stage = None
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue3835'
    versions = ['Python 3.3']

    @HWJ
    Copy link
    Mannequin Author

    HWJ mannequin commented Sep 11, 2008

    With version 3.0 (SVN 66386)

    import pydoc
    pydoc.gui()

    gives

    >>> Exception in thread Thread-1:
    Traceback (most recent call last):
      File "/usr/local/lib/python3.0/threading.py", line 507, in 
    _bootstrap_inner
        self.run()
      File "/usr/local/lib/python3.0/threading.py", line 462, in run
        self._target(*self._args, **self._kwargs)
      File "/usr/local/lib/python3.0/pydoc.py", line 1989, in serve
        DocServer(port, callback).serve_until_quit()
      File "/usr/local/lib/python3.0/pydoc.py", line 1971, in __init__
        self.base.__init__(self, self.address, self.handler)
      File "/usr/local/lib/python3.0/socketserver.py", line 401, in __init__
        self.server_activate()
      File "/usr/local/lib/python3.0/pydoc.py", line 1982, in 
    server_activate
        if self.callback: self.callback(self)
      File "/usr/local/lib/python3.0/pydoc.py", line 2072, in ready
        text='Python documentation server at\n' + server.url)
      File "/usr/local/lib/python3.0/tkinter/__init__.py", line 1199, in 
    configure
        return self._configure('configure', cnf, kw)
      File "/usr/local/lib/python3.0/tkinter/__init__.py", line 1190, in 
    _configure
        self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
    _tkinter.TclError: out of stack space (infinite loop?)

    @HWJ HWJ mannequin added extension-modules C modules in the Modules dir type-crash A hard crash of the interpreter, possibly with a core dump labels Sep 11, 2008
    @gpolo
    Copy link
    Mannequin

    gpolo mannequin commented Sep 14, 2008

    What tcl/tk version are you using ?

    Also, can you put a "print(_flatten((self._w, cmd)) +
    self._options(cnf))" before the line 1190 in
    /usr/local/lib/python3.0/tkinter/init.py and tell what it shows when
    you call pydoc.gui ?

    @HWJ
    Copy link
    Mannequin Author

    HWJ mannequin commented Sep 15, 2008

    I'm using Tcl/Tk 8.5.4 here

            print(":::")
            print(_flatten((self._w, cmd)) + self._options(cnf))
    produces:
    :::
    ('.3073836300', 'configure', '-yscrollcommand', '3077632332set')
    :::
    ('.3073835564.3073835660', 'configure', '-text', 'Python documentation 
    server at\nhttp://localhost:7464/')
    >>> Exception in thread Thread-1:
    Traceback (most recent call last):
      File "/usr/local/lib/python3.0/threading.py", line 507, in 
    _bootstrap_inner
        self.run()
      File "/usr/local/lib/python3.0/threading.py", line 462, in run
        self._target(*self._args, **self._kwargs)
      File "/usr/local/lib/python3.0/pydoc.py", line 1989, in serve
        DocServer(port, callback).serve_until_quit()
      File "/usr/local/lib/python3.0/pydoc.py", line 1971, in __init__
        self.base.__init__(self, self.address, self.handler)
      File "/usr/local/lib/python3.0/socketserver.py", line 401, in __init__
        self.server_activate()
      File "/usr/local/lib/python3.0/pydoc.py", line 1982, in 
    server_activate
        if self.callback: self.callback(self)
      File "/usr/local/lib/python3.0/pydoc.py", line 2072, in ready
        text='Python documentation server at\n' + server.url)
      File "/usr/local/lib/python3.0/tkinter/__init__.py", line 1201, in 
    configure
        return self._configure('configure', cnf, kw)
      File "/usr/local/lib/python3.0/tkinter/__init__.py", line 1192, in 
    _configure
        self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
    _tkinter.TclError: out of stack space (infinite loop?)

    @gpolo
    Copy link
    Mannequin

    gpolo mannequin commented Sep 15, 2008

    Uhm, is it caused only by the combination of tk 8.5.4 and py3k, or does
    the same happen with tk 8.5.4 and python-trunk ? What about tk 8.5.3 (or
    some other of tk 8.5 series) or even tk 8.4.16 and {python-trunk, py3k} ?

    It would be good if you could test some other combination, specially
    because I can't reproduce it here with other versions (but I'm compiling
    8.5.4 here now).

    @gpolo
    Copy link
    Mannequin

    gpolo mannequin commented Sep 16, 2008

    Just reproduced the issue under python-trunk with tcl/tk 8.5.4 and 8.5.3

    @gpolo
    Copy link
    Mannequin

    gpolo mannequin commented Sep 16, 2008

    But it happens only if you don't build tcl/tk with --enable-threads =)

    @gpolo
    Copy link
    Mannequin

    gpolo mannequin commented Sep 16, 2008

    If you remove the widget.config calls in GUI.ready you will notice the
    problem "goes away", but note that this method is called from another
    thread while you have a non-thread-safe tcl/tk lib (I'm assuming you
    didn't compile it with --enable-threads). So.. using multiple threads in
    Python while Tcl is compiled without --enable-threads isn't supported at
    all.

    To reproduce the problem try this (change Tkinter to tkinter if py3k):

    import threading
    import Tkinter
    
    lbl = Tkinter.Label(text="hi")
    threading.Thread(target=lambda: lbl.configure(text="hi there")).start()
    lbl.mainloop()

    If your tcl/tk libs weren't compiled with --enable-threads this should
    get you an "TclError: out of stack space (infinite loop?)". A
    documentation note may be added somewhere, but nothing much else is
    going to happen (that is what I believe at least).

    @HWJ
    Copy link
    Mannequin Author

    HWJ mannequin commented Sep 17, 2008

    Many thanks, that solved the problem.

    Since the cause of the problem wasn't easy to find out
    (for me, at least)

    would be possible to check at import time if Tcl/Tk has been
    configured with threads enabled?

    Helmut.

    @gpolo
    Copy link
    Mannequin

    gpolo mannequin commented Sep 17, 2008

    The patch attached checks for that when an interpreter is created, not
    really at import time but should be enough.

    But my real concern is that tkinter thinks it will work properly when
    Python is using threads and Tcl wasn't compiled with --enable-threads.
    Maybe that was true some time ago or maybe in other platforms, but isn't
    the case anymore.

    @asvetlov
    Copy link
    Contributor

    Push updated patch for tip (3.3) head

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 13, 2012

    New changeset d731dcda2611 by Martin v. Löwis in branch 'default':
    Issue bpo-3835: Refuse to use unthreaded Tcl in threaded Python.
    http://hg.python.org/cpython/rev/d731dcda2611

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Mar 13, 2012

    Thanks for the patch!

    @loewis loewis mannequin closed this as completed Mar 13, 2012
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 14, 2012

    New changeset 7cbc48324938 by Andrew Svetlov in branch 'default':
    Revert the patch for bpo-3835 because failed on Windows buildbot
    http://hg.python.org/cpython/rev/7cbc48324938

    @asvetlov
    Copy link
    Contributor

    Recall to 'open' state

    @asvetlov asvetlov reopened this Mar 14, 2012
    @asvetlov
    Copy link
    Contributor

    Close as 'not a bug' because Guilherme's test to reproduce the bug from msg73304 works good at least for Linux.
    Windows version of Tcl/Tk compiled without threading support.

    So current behavior is correct and should not to be fixed.

    @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
    extension-modules C modules in the Modules dir topic-tkinter type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants