| Ticket UUID: | 704212 | |||
| Title: | [focus] dumps core with certain extensions | |||
| Type: | Bug | Version: | obsolete: 8.4.2 | |
| Submitter: | nobody | Created on: | 2003-03-15 18:28:14 | |
| Subsystem: | 55. [focus] | Assigned To: | jan.nijtmans | |
| Priority: | 8 | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2026-10-05 07:30:25 | |
| Resolution: | Fixed | Closed By: | jan.nijtmans | |
| Closed on: | 2026-10-04 20:59:44 | |||
| Description: |
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
| |||
| User Comments: |
serhiy.storchaka added on 2026-10-05 07:30:25:
Backported to 8.6 in [49d74ea438]. jan.nijtmans added on 2026-10-04 20:59:44: Fixed in [78b981bf|trunk] and core-9-0-branch Many thanks! Closing serhiy.storchaka added on 2026-09-19 16:27:41: Still relevant: TkSetFocusWin() passes the result of TkpGetWrapperWindow() to TkpChangeFocus() unchecked, and on X11 it is NULL for a top of hierarchy window without wm information. Applied the suggested fix: focus now uses the window itself when it has no wrapper, instead of crashing. Fixed in [65b5b1ae41] (branch focus-no-wrapper). mckay added on 2004-12-14 19:18:58: 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. dkf added on 2004-12-13 21:03:52: Logged In: YES user_id=79902 Is this still relevant post TIP#153? hobbs added on 2003-05-11 08:15:38: File Added - 50089: tkFocus.704212 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. | |||
Attachments:
- tkFocus.704212 [download] added by hobbs on 2003-05-11 08:15:38. [details]
