Tk Source Code

View Ticket
Login
Ticket UUID: f7d4e4102ef355313725494beb351f21771afd85
Title: [$canvas postscript] crashes on X11 with never mapped windows
Type: Bug Version: 8.6-trunk
Submitter: emiliano Created on: 2025-05-13 00:56:25
Subsystem: 06. Canvas Postscript Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Severe
Status: Closed Last Modified: 2026-09-30 19:00:07
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2026-09-30 19:00:07
Description:

Running the following script

package require Tk
pack [canvas .c]
.c create window 5000 100 -window [label .c.l] ; # make sure is off screen
.c postscript -x 0 -y 0 -width 6000 -height 300 ; #include the window

results in

X Error of failed request:  BadDrawable (invalid Pixmap or Window parameter)
  Major opcode of failed request:  73 (X_GetImage)
  Resource id in failed request:  0x0
  Serial number of failed request:  1723
  Current serial number in output stream:  1723

Tested with 8.6.8 and 9.1a0 (trunk)

The offending line (in trunk) is this

The problem is that, for never mapped windows, Tk_WindowID(tkwin) is None. Calling Tk_MakeWindowExist(tkwin); before fixes the crash.

User Comments: jan.nijtmans added on 2026-09-30 19:00:07:

Fixed [6d4d39d8de896425|here], also backported to core-9-0-branch and core-8-6-branch


serhiy.storchaka added on 2026-09-18 10:26:21:

Fixed on branch canvas-ps-unmapped-window in [3be01a1c7b]: CanvasPsWindow() now skips windows which are not mapped, since XGetImage() cannot copy them anyway (it fails with BadMatch for an existing unmapped window, and with BadDrawable, which was not caught, for a window which was never created).