Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: ffe6b06dd3b2509befaf4d9e4b146ef8f0ea3ce1
Ticket: 3603434fffffffffffffffffffffffffffffffff
Win TclpObjNormalizePath fails for non-existent drive
User & Date: dgp on 2013-02-05 16:38:31
Changes

  1. assignee changed to: "dgp"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    
    The portions of filesystem pathname handling in
    the generic/*.c files of Tcl include special per-platform
    handling of [file pathtype] queries.  In particular, on
    Windows, any pathname starting with ?:/ , where ?
    is any single byte, gets labeled as an absolute path
    based on the assumption that it's a drive designation.
    This happens whether or not such a drive is actually
    on the system.
    
    Over in the tclWinFile.c implementation of
    TclpObjNormalizePath(), though, a normalization
    of  a path of the same pattern, say "a:/", is more
    constrained.  If the "a" drive is not actually on
    the system (floppy drives are uncommon now),
    it refuses to declare that "a:/" is a normalized
    pathname.  Instead, it claims "a:" is a normalized
    pathname, and leaves the rest for other filesystems
    to continue normalizing.  This is trouble and inconsistent.
    The cooperative normalization process relies on working
    on an absolute pathname, and this misstep leaves us
    with a volumerelative one.  It's also inconsistent with the
    rules imposed in the generic code.
    
    Most of the time this bug is harmless, because no other
    filesystem is present or makes an effort to claim, and the
    final fallback is to give it native ownership and just assume
    what's left is normalized.  This turns out to be correct.  The
    only time this causes trouble is when the 
    Tcl_FSNormalizePathProc of some other Tcl_Filesystem
    recursively calls for a prefix of the path to be normalized
    as part of its own attempt to normalize more of the path.
    For example, this is what trofs does.  Then the bug leads
    to endless recursion and a crash when the stack is exhausted.
    Thanks to Brian Griffin for taking notice of this.  Demonstration
    isn't difficult.  On Windows, bring trofs into an interp and then
    attempt a [glob a:/] on a system with no A: drive.  CRASH!
    
    The simplest way to restore consistency is to make sure 
    TclpObjNormalizePath claims the first / in the path as part
    of a normalized path, whether or not the drive exists on
    the system.  Then the assumptions of the cooperative
    normalization among Tcl_Filesystems are maintained and
    crashes are avoided.
    
    To be clear, this is not the "most correct" solution.  Getting
    something more correct involves some serious rewriting so
    that platform processing is better contained in platform files.
    This is a minimal consistency and sanity and crash prevention
    fix given the state of things as they are.
    
  4. foundin changed to: "None"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "dgp"
  10. subsystem changed to: "36. Pathname Management"
  11. title changed to:
    Win TclpObjNormalizePath fails for non-existent drive
    
  12. type changed to: "Bug"