Tk Source Code

View Ticket
Login
Ticket UUID: 2128972
Title: wish 8.5.4 core dump
Type: Bug Version: obsolete: 8.5.4
Submitter: lvirden Created on: 2008-09-25 18:53:05
Subsystem: 75. wish Assigned To: georgeps
Priority: 7 High Severity:
Status: Closed Last Modified: 2026-10-22 17:22:35
Resolution: Invalid Closed By: serhiy.storchaka
    Closed on: 2026-10-08 14:17:43
Description:
platform: sparc solaris 9
tcl/tk: 8.5.4

A developer emailed me today, asking why their tcl application was core dumping.  I stopped by, and here is what I found.

The application - assignee_edit - a purely tcl script - began:

#! /vol/tclsrcsol/tcl85test/bin/wish8.5 -f

:tk and tcl code

The core file says:
dbx /vol/tclsrcsol/tcl85test/bin/wish8.5 core 
For information about new features see `help changes'
To remove this message, put `dbxenv suppress_startup_message 7.0' in your .dbxrc 
Reading wish8.5
dbx: core object name "assignee_edit" doesn't match object name "wish8.5"
core file ignored. 
Use -f to force loading of corefile
:
:
So, I typed:
$ dbx -f /vol/tclsrcsol/tcl85test/bin/wish8.5 core 
For information about new features see `help changes'
To remove this message, put `dbxenv suppress_startup_message 7.0' in your .dbxrc 
Reading wish8.5 core file 
header read successfully 
Reading ld.so.1 
Reading libtk8.5.so 
Reading libtcl8.5.so 
Reading libX11.so.4 
Reading libXext.so.0 
Reading libdl.so.1 
Reading libsocket.so.1 
Reading libnsl.so.1 
Reading libm.so.1 
Reading libc.so.1 
Reading libmp.so.2 
Reading libc_psr.so.1 
Reading libtclx8.4.so 
Reading libOratcl4.4.so 
Reading libclntsh.so.9.0 
Reading libwtc9.so 
Reading libgen.so.1 
Reading libsched.so.1 
Reading libaio.so.1 
Reading librt.so.1 
Reading libmd5.so.1 
Reading libmd5_psr.so.1 
program terminated by signal SEGV (no mapping at the fault address) 
Current function is Tcl_NextHashEntry
  587           if (searchPtr->nextIndex >= tablePtr->numBuckets) {
(dbx) where
=>[1] Tcl_NextHashEntry(searchPtr = 0xffbfdc68), line 587 in "tclHash.c"
  [2] Tcl_FirstHashEntry(tablePtr = (nil), searchPtr = 0xffbfdc68), line 553 in "tclHash.c"
  [3] Oratcl_Clean(clientData = 0x6a478), line 217 in "oratcl.c"
  [4] Oratcl_Exit(clientData = 0x6a478), line 274 in "oratcl.c"
  [5] Tcl_Finalize(), line 949 in "tclEvent.c"
  [6] Tcl_Exit(status = 0), line 828 in "tclEvent.c"
  [7] Tk_MainEx(argc = -1, argv = 0xffbfe0f0, appInitProc = 0x114c8 = &Tcl_AppInit(Tcl_Interp *interp), interp = 0x2abc0), line 325 in "tkMain.c"
  [8] main(argc = 3, argv = 0xffbfe0e4), line 68 in "tkAppInit.c"

Now, looking at the stack trace, one might think "hmm, probably an Oratcl error".

Here's the kicker.

For grins, I changed the script to read:

#! /vol/tclsrcsol/tcl85test/bin/tclsh8.5

package require Tk

and now the program does not generate the core dump.

Also, I have written the script:

#! /vol/tclsrcsol/tcl85test/bin/wish8.5 -f
pack [button .quit -text Quit -command exit}

and it runs without a core dump, so it doesn't seem like the length of the magic line is the issue.
User Comments: serhiy.storchaka added on 2026-10-08 14:17:43:

The crash is in Oratcl: its exit handler (Oratcl_Exit → Oratcl_Clean) uses the hash table of an interpreter which was already deleted. When the last window is closed, wish deletes the interpreter and then calls Tcl_Exit, so the exit handlers run after the interpreter deletion callbacks. tclsh evaluates exit while the interpreter still exists, which is why the script did not crash there. Oratcl should handle the deleted interpreter in its exit handler, or remove the exit handler when the interpreter is deleted.


dgp added on 2008-09-30 00:45:36:
A finalization crash only in exit
from Tk_Main sounds related to issues
GPS has been examining.