#1709 Inserting Big Image in Canvas crashes wish (aqua)

obsolete: 8.4.5

If an image has more than 4k pixels in height or width then
trying to add the image to a canvas causes Wish Shell to

This is with Tcl/Tk 8.4.5 on Mac OS X 10.3.3

Here is a partial dump:
Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_INVALID_ADDRESS (0x0001) at 0x8a0080ff

Thread 0 Crashed:
0 com.apple.QD 0x94d4044c GetPMBaseAddr +
1 com.apple.QD 0x94d391e4
PixMapToNQDPixMap + 0x24
2 com.apple.QD 0x94d3bf7c BitsToPix + 0x160
3 com.apple.QD 0x94d39a04 Stretch + 0x134
4 com.apple.QD 0x94d4ac4c OneSrcOneDst +
5 com.apple.QD 0x94d40538 BitsDevLoop + 0xcc
6 com.apple.QD 0x94d39568 CommonBits +
7 com.apple.QD 0x94d41200 StdBits + 0x2b4
8 com.apple.QD 0x94d394e8 CommonBits +
9 com.apple.QD 0x94d43694 CopyBits + 0x36c
10 com.tcltk.tklibrary 0x0b079584 TkPutImage +
11 com.tcltk.tklibrary 0x0b0443fc DitherInstance +
12 com.tcltk.tklibrary 0x0b040ab0
ImgPhotoConfigureInstance + 0x1d0
13 com.tcltk.tklibrary 0x0b040de8 ImgPhotoGet +
14 com.tcltk.tklibrary 0x0b039cac Tk_GetImage +
15 com.tcltk.tklibrary 0x0b012fa8 ConfigureImage +
16 com.tcltk.tklibrary 0x0b012d64 CreateImage +
17 com.tcltk.tklibrary 0x0b00cb44 CanvasWidgetCmd
+ 0x9a8


  • Jeffrey Hobbs

    Jeffrey Hobbs - 2004-05-07
    • assigned_to: hobbs --> das
  • Daniel A. Steffen

    Logged In: YES

    (repost from tcl-mac)

    I remember this crash from mac classic... it is due to a
    limitation with QuickDraw Pixmaps, they cannot be more than
    4096 pixels wide. The crash occurs in the CopyBits in
    TkPutImage() right ?

    I added a panic for this problem in tk mac classic a long time

    2002-04-08 Daniel Steffen <das@users.sourceforge.net>

    * mac/tkMacDraw.c: add panic for overwide
    TkImages that would
    crash Tk on mac otherwise.

    c.f. patch below, but clearly this happened after the mac sources
    were cloned and adapted for macosx, as tkMacOSXDraw.c
    doesn't have the panic...

    at least this same panic should be added there, a better solution
    would of course be to CopyBits the image in several slices of at
    most 4096 pixels width.

    Index: tkMacDraw.c

    RCS file: /cvsroot/tktoolkit/tk/mac/Attic/tkMacDraw.c,v
    retrieving revision 1.8
    retrieving revision
    diff -u -p -r1.8 -r1.8.2.1
    --- tkMacDraw.c 14 Dec 1999 06:52:56 -0000 1.8
    +++ tkMacDraw.c 8 Apr 2002 09:00:32 -0000
    @@ -10,7 +10,7 @@
    * See the file "license.terms" for information on usage and
    * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    - * RCS: @(#) $Id: tkMacDraw.c,v 1.8 1999/12/14 06:52:56
    hobbs Exp $
    + * RCS: @(#) $Id: tkMacDraw.c,v 2002/04/
    08 09:00:32 das Exp $

    #include "tkInt.h"
    @@ -370,6 +370,9 @@ TkPutImage(
    pixmap.pmTable = NULL;
    pixmap.pmReserved = 0;
    pixmap.baseAddr = image->data;
    + if (image->bytes_per_line >= 0x4000) {
    + panic("TkImage too wide!");
    + }
    pixmap.rowBytes = image->bytes_per_line | 0x8000;

    CopyBits((BitMap *) &pixmap, &((GrafPtr) destPort)-

  • Jeffrey Hobbs

    Jeffrey Hobbs - 2006-05-29
    • priority: 5 --> 6
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2006-05-29

    Logged In: YES

    Couldn't we just restrict it to copy up to the limit in a
    special if case? It wouldn't be perfect, but it would be
    better than a panic, and may well work for others until we
    get rid of the QD stuff.

  • Daniel A. Steffen

    Logged In: YES

    drawing in multiple slices is about the same amount of work
    as restricting to the limit, as the image has to be copied
    into a new buffer in either case...

    attached a patch that should implement copybits of an
    overwide image in multiple slices, it compiles and does not
    affect drawing of narrow images but wide images are not
    tested yet.

    if images are drawn scaled there may be visible artifacts at
    slice boundaries that are unavoidable, as the slices need to
    end at screen pixel boundaries, i.e. scaled image pixels may
    be drawn too wide at slice boundaries.

  • Nobody/Anonymous

    Logged In: NO

    attached revised patch that works correctly with wide color
    and B&W images.

    committed to HEAD and core-8-4-branch

  • Nobody/Anonymous

    • status: open --> closed-fixed

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks