Tk Source Code

View Ticket
Ticket UUID: 5ee8af61e5ef8e233158a43459624f4ecf58a6fe
Title: Window embedding can not work on 64-bit Unix and Windows
Type: Bug Version:
Submitter: storchaka Created on: 2015-11-09 13:46:26
Subsystem: 68. Win Window Operations Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2016-08-22 08:25:48
Resolution: Fixed Closed By: dkf
    Closed on: 2016-08-22 08:25:48
There is an issue with parsing 64-bit window id. If the window id happens to be above 4GiB or even 2GiB limit, the "toplevel -use" and "winfo pathname" commands will not work.

On all 64-bit platforms the "winfo id" command returns 64-bit integer formatted as a hexadecimal string, the -use option of the toplevel widget uses Tcl_GetInt to parse it and therefore works only with 32-bit integers.

There is the similar issue with the "winfo pathname" command. On Unix it always uses Tcl_GetInt, on 64-bit Windows it tries to parse the string with sscanf(string, "0x%p", &win.hwnd), but this doesn't work with decimal and octal strings that the winfo pathname command should accept, and perhaps doesn't work on Cygwin at all (because %p already includes 0x). See also bug #2026405 (

May be this bug is related to random failures of Python buildbots on 64-bit Windows (
User Comments: storchaka added on 2015-11-10 15:24:05:
Thank you for quick fix.

But I have doubt. Is the Window type always has the same size as long on Unix? In /usr/include/X11/X.h on my machine it is defined 32-bit on 64-bit platform.

typedef CARD32 XID;
typedef XID Window;

But in xlib/X11/X.h in Tk sources tree it's definition is different:

typedef unsigned long XID;
typedef XID Window;

One minor issue is left. "winfo pathname" doesn't work with decimal and octal 64-bit integers on Windows. May be use Tcl_GetWideIntFromObj?

jan.nijtmans added on 2015-11-10 13:59:01:
Fixed on Win64 as well, in both core-8-5-branch and trunk

jan.nijtmans added on 2015-11-09 15:46:00:
Should be fixed now for Unix in both core-8-5-branch and trunk.

I will have a look at the Windows part as well. Stay tuned.