TIP 741: Cleanup of temporary Windows DLL's loaded from zipfs archives

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Author:             Ashok P. Nadkarni <apnmbx-public@yahoo.com>
Tcl-Version:        9.1
State:              Draft
Type:               Project
Created:            2025-12-02
Tcl-Branch:         tip-741

Abstract

This TIP proposes an alternative solution to the problem described in TIP 709. Quoting that TIP,

This TIP is meant to solve a longstanding bug in the implementation of the VFS loader for Windows. On Windows a dynamically-linked library (DLL) residing in a VFS (e.g. a mounted zip-file) is copied to a temporary directory before being loaded. This directory is never cleaned up, resulting in left-over temporary directories with every tclsh/wish run. The bug is present in all Tcl releases (8.6 too**, but it became more visible in 9.0 because of the added support for a zipfs.

While TIP 709 proposes loading of DLL's directly from the zipfs file system, this TIP preserves the current mechanism of copying the DLL's to a temporary directory on disk but cleans up the directory on process exit so temporary files are left behind. The author's reservations about TIP 709 that necessitated this TIP are noted in this post.

Specification

The function TclpFinalizeLoad is added which is invoked at the time of Tcl finalization. On non-Windows platforms, this is a no-op. On Windows, the function calls CreateProcess to invoke cmd.exe to delete the directory stored in the global dllDirectoryName after a delay using the timeout.exe program to allow for application exit. The timeout program is available starting with Windows Vista.

Note the tracking of the temporary directory in the dllDirectoryName variable already exists in 9.0 and is not something new added in this TIP.

Implementation notes

Implementation is in the tip-741 branch.

References

For further background on this topic, see this and this in the core mailing list, and the related ticket.

Copyright

This document has been placed in the public domain.

History