Menu

#987 pkg_mkIndex [pwd] xbit81.dll

obsolete: 8.1
closed-fixed
nobody
2
2001-04-05
2000-10-26
Anonymous
No

OriginalBugID: 2570 Bug
Version: 8.1
SubmitDate: '1999-08-18'
LastModified: '2000-03-06'
Severity: SER
Status: Released
Submitter: techsupp
ChangedBy: ericm
OS: Windows 95
Machine: X86
FixedDate: '2000-03-06'
FixedInVersion: 8.3.1
ClosedDate: '2000-10-25'

Name:
Chengye Mao

Extensions:
xbit81.dll version 1.0

Comments:
Summary:
1) varible tcl_pkgPath is missing.
2) Either pkg_mkIndex procedure or some Tk code need to modified. A
modification of pkg_mkIndex is provided and it works fine.

ReproducibleScript:
I was using wish81 at a Windows 95 platform and
trying to install a xbit package by using the following script:

pkg_mkIndex [pwd] xbit81.dll

ObservedBehavior:
The wish81 application crashed.

DesiredBehavior:
I have done the package installation for wish42 and wish80 with
successes.
There are no problems in loading xbit81.dll. I expected no problems in
package
installation for wish81. I also expected the Tcl variable tcl_pkgPath to
contain the path of the package directory, but could not find it. The
variable tcl_pkgPath is missing in wish81!

Patch:
I traced the bug into some xbit81.dll's C code that try to access the window's information. The crash was caused by these code such as
Tk_MakeWindowExist(tkwin);
scrnNumber = Tk_ScreenNumber(tkwin);
disp = Tk_Display(tkwin);
scrnPtr = Tk_Screen(tkwin);
cmap = Tk_Colormap(tkwin);
depth = Tk_Depth(tkwin);
indicating an invalid structure was accessed to by these code.

I then traced the script of pkg_mkIndex and found that the problem was due to
loading Tk package with a geometry +0+0, which causes invalid window structure.
Please see my comments in the following fixed scripts:

proc pkg_mkIndex {dir args} {
global errorCode errorInfo
append index "# Tcl package index file, version 1.0\n"
append index "# This file is generated by the \"pkg_mkIndex\" command\n"
append index "# and sourced either when an application starts up or\n"
append index "# by a \"package unknown\" script. It invokes the\n"
append index "# \"package ifneeded\" command to set up package-related\n"
append index "# information so that packages will be loaded automatically\n"
append index "# in response to \"package require\" commands. When this\n"
append index "# script is sourced, the variable \$dir must contain the\n"
append index "# full path name of this file's directory.\n"
set oldDir [pwd]
cd $dir
foreach file [eval glob $args] {
# For each file, figure out what commands and packages it provides.
# To do this, create a child interpreter, load the file into the
# interpreter, and get a list of the new commands and packages
# that are defined. Define an empty "package unknown" script so
# that there are no recursive package inclusions.

set c [interp create]

# If Tk is loaded in the parent interpreter, load it into the
# child also, in case the extension depends on it.

foreach pkg [info loaded] {
if {[lindex $pkg 1] == "Tk"} {
#
# Comment of Chengye Mao
# The following script causes crash in making package of xbit81.dll
# pkg_mkIndex worked fine after it was commented out.
# $c eval {set argv {-geometry +0+0}}

load [lindex $pkg 0] Tk $c
#
# Comment of Chengye Mao
# The following line was added to void side-effect of showing a main window
# during making a pkgIndex.tcl with pkg_mkIndex
#
$c eval wm withdraw .
break
}
}
$c eval [list set file $file]
if [catch {
$c eval {
proc dummy args {}
package unknown dummy
set origCmds [info commands]
set dir "" ;# in case file is pkgIndex.tcl
set pkgs ""

# Try to load the file if it has the shared library extension,
# otherwise source it. It's important not to try to load
# files that aren't shared libraries, because on some systems
# (like SunOS) the loader will abort the whole application
# when it gets an error.

if {[string compare [file extension $file] [info sharedlibextension]] == 0} {

# The "file join ." command below is necessary. Without
# it, if the file name has no \'s and we're on UNIX, the
# load command will invoke the LD_LIBRARY_PATH search
# mechanism, which could cause the wrong file to be used.

load [file join . $file]
set type load
} else {
source $file
set type source
}
foreach i [info commands] {
set cmds($i) 1
}
foreach i $origCmds {
catch {unset cmds($i)}
}
foreach i [package names] {
if {([string compare [package provide $i] ""] != 0)
&& ([string compare $i Tcl] != 0)
&& ([string compare $i Tk] != 0)} {
lappend pkgs [list $i [package provide $i]]
}
}
}
} msg] {
puts "error while loading or sourcing $file: $msg"
}

foreach pkg [$c eval set pkgs] {
lappend files($pkg) [list $file [$c eval set type] [lsort [$c eval array names cmds]]]
}
interp delete $c
}
foreach pkg [lsort [array names files]] {
append index "\npackage ifneeded $pkg \[list tclPkgSetup \$dir [lrange $pkg 0 0] [lrange $pkg 1 1] [list $files($pkg)]\]"
}
set f [open pkgIndex.tcl w]
puts $f $index
close $f
cd $oldDir
}

PatchFiles:
The effected file: ../lib/tcl8.1/init.tcl

tcl_pkgPath is not used on Windows, thus its absence. I applied your patch, with slight modification to account for source changes between 8.1 and 8.3. The fix will go out with 8.3.1.

- eric

-- 03/06/2000 ericm

Discussion

  • Brent B. Welch

    Brent B. Welch - 2000-10-26
    • priority: 5 --> 2
    • status: open --> closed-fixed
     
  • Don Porter

    Don Porter - 2001-04-05
    • labels: 104248 --> 39. Package Manager