#4026 Global grab can cause app to segfault

obsolete: 8.5.2
69. Other (102)
Trevor Williams

I have attached a simple script that can cause wish to segfault when run. To replicate, simply type 'source test.tcl' at the wish prompt and follow the instructions of the various windows. I am running this using Tcl/Tk version 8.5.2, running on Mac OS X 10.5.3 on a Intel-based iMac.


  • Sample Tcl/Tk script to reproduce problem.

  • Logged In: YES
    Originator: YES

    Assigning this to Daniel per his request.

    • assigned_to: nobody --> das
  • Logged In: YES
    Originator: NO

    Thanks much, that script made reproducing the crash easy.

    The attached patch fixes the crash, it turned out to be a bug in generic tkPointer code, the global . grab was not being restored correctly when the temporary grab for the .c.b button mousebutton press/release cycle was removed, leading to a dangling reference to .c inside the TkpSetCapture() implementation which was not cleaned up when .c was destroyed in the button command. Subsequent reference to the grab window from mouse-move event generation code would then segfault...

    Fix committed to HEAD, core-8-5-branch and core-8-4-branch.

    Note that this is a tk bug and should have been filed in the tktoolkit tracker (not bothering to refile it since it is fixed).

    • priority: 5 --> 9
    • status: open --> closed-fixed