Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 92e1475569bd99c16dd7147bf9575f2cf9d843705989e4af713e9e5aaac4b34d
Ticket: a8e4f76ce498ad648134e0b6867c359949055388
load library (dll) from zipfs-library causes a leak in temporary folder
User & Date: apnadkarni on 2024-11-25 06:17:18
Changes

  1. icomment:
    To respond to Jan's post,
    
    The issue is not with Windows PE format changing, it has to do with how the Windows loader interprets the *content* of the records and to what extent MemoryModule faithfully implements that behavior.
    
    - Does it process SEH records in the PE to set up exception handler chains?
    
    - Does it call C++ constructors for globals, and in the correct order?
    
    - Does it process *declared* TLS variables (_declspec(thread) decorations) and arrange for memory to be allocated for them at every thread creation? Will it pin the DLL in memory as required?
    
    - Does it handle manifest records in the DLL? For example, a DLL may require a specific version of a dependency specified via a side-by-side assembly manifest record.
    
    - Does it deal with differences within Windows versions? TLS handling for example has changed and the implementation in the MemoryModule would have to pick the correct one depending on OS version.
    
    - What happens if the DLL contains resources accessed by the code? Will LoadResource accept the handle passed by MemoryModule to the DLL entry point?
    
    This is just what I can think of based on my limited knowledge of Windows loaders. There are likely other concerns.
    
    I have not looked at the MemoryModule code and even if I did I probably could not tell if it does all the above. Based on the tickets though, I think it does none of it.
    
    The comments regarding Tcl C API not using SEH is irrelevant. Extensions can internally use SEH.
    
    For TLS, using Tcl's TLS API is not an alternative. Even ignoring the performance issues, it would require extensions to (a) change implementation and (b) not even be feasible in some cases as the API's and semantics are not the same. And as a practical matter, tclcurl uses libcurl which in turn uses another dozen or more libraries. How is it even possible for these to be changed to use the Tcl TLS API?
    
    The stance that if the mechanism does not work for some extension, we can just mark the bug as not supported does not sit well with me. For starters, with TLS stomping, bugs would show up as memory violations (best case) or data corruption (worst case). Just tracking it down and pinpointing MemoryModule would be considerable work. Think about the tclcurl example above. Remember that the inclusion of an extension within the VFS is not within the extension writer's control but they are the ones who will expend effort on debugging. 
    
    Finally, as a matter of principle I am opposed to introducing features into the core that will work some of the time for some of the extensions. That is not a path to robustness.
    
    I understand the risk/reward is all a matter of opinion so if majority of folks want it, so be it. I do think something of this nature should have a TIP (targeting 9.1 and not 9.0.1) and not be just treated as an implementation change or bug fix. That will allow a full range of tests.
    
  2. login: "apnadkarni"
  3. mimetype: "text/x-markdown"