Menu

#1444 [focus] dumps core with certain extensions

obsolete: 8.4.2
open
8
2003-10-03
2003-03-15
Anonymous
No

The [focus] command will dump core if the target window
is a widget
with certain unusual characteristics. If the target
window is the top
of a window hierarchy but is NOT a toplevel with a
wrapper window,
it will core dump. To demonstrate the problem, get the
"rootwin"
widget extension (which makes the X display's root
window into
a Tk widget):

http://www.eecs.umich.edu/~mckay/computer/rootwin0.4.tar.gz

Then do the following:

load /path/to/libRootwin0.4.so
rootwin .r
focus -force .r

The problem is in tkFocus.c; I fixed it, and the diff
looks like:

diff tkFocus.c.orig tkFocus.c
565c565
< TkWindow *topLevelPtr;
---
> TkWindow *topLevelPtr, *focusToplevelPtr;
667c667,671
< serial =
TkpChangeFocus(TkpGetWrapperWindow(topLevelPtr), force);
---
> focusToplevelPtr =
TkpGetWrapperWindow(topLevelPtr);
> if (focusToplevelPtr == NULL) {
> focusToplevelPtr = topLevelPtr;
> }
> serial = TkpChangeFocus(focusToplevelPtr, force);

NOTE: there's a bad line break in the diff, but you can
see that
the fix is simple. Address questions to:

mckay at eecs dot umich dot edu

Discussion

  • Jeffrey Hobbs

    Jeffrey Hobbs - 2003-05-11
    • priority: 5 --> 7
     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2003-05-11

    Logged In: YES
    user_id=72656

    attached is a clean patch against the HEAD, but I have focus
    issues when running the tests on linux that I would like to
    understand better first.

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2003-05-11
     
  • Don Porter

    Don Porter - 2003-10-03
    • priority: 7 --> 8
     
  • Donal K. Fellows

    Logged In: YES
    user_id=79902

    Is this still relevant post TIP#153?

     
  • Neil McKay

    Neil McKay - 2004-12-14

    Logged In: YES
    user_id=131705

    Yes, I believe this bug is still relevant post TIP#153. In
    fact this bug has to be fixed in order for TIP#153 to be
    useful. This is a place where the Tk code assumes that the
    top-level window in a hierarchy is an actual [toplevel]
    widget (or, more correctly, it assumes that the
    top-of-hierarchy widget has a wrapper window). If it is not
    a toplevel, the code dereferences a NULL pointer.