Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: b6f59059f8cee1ddf6b560864016ea21ca8a614e
Ticket: 218508ffffffffffffffffffffffffffffffffff
Hash table corruption when rebuildLiteralTable occurs (invo
User & Date: nobody on 2000-10-26 01:01:27
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 765 Bug
    Version: 8.1a2
    SubmitDate: '1998-10-27'
    LastModified: '1998-12-08'
    Severity: SER
    Status: Released
    Submitter: pat
    ChangedBy: stanton
    RelatedBugIDs: 764
    OS: All
    OSVersion: NA
    Machine: NA
    FixedDate: '1998-12-08'
    FixedInVersion: 8.1b1
    ClosedDate: '2000-10-25'
    
    
    Subject: Hash table corruption when rebuildLiteralTable  occurs (invoked from TclRegisterLiteral) during compilation
    From: [email protected]
    
    TclTk Bug Report Form filled out by:  [email protected]
    
    Name:  Adam Grove
    BugOrRFE:  Bug
    Product:  Tcl
    Version:  8.1a2
    OperatingSystem:  WinNT
    OperatingSystemVersion:  4.0
    Extensions:  none
    CustomShell:  None; but compiled with the multithreading options. 
    Synopsis:  Hash table corruption when rebuildLiteralTable  occurs (invoked from TclRegisterLiteral) during compilation
    
    ReproducibleScript:
    Not really possible. This is a very time/situation dependent bug which I have
    not been able to reduce to a small test.  
    
    ObservedBehavior:
    The observed behaviour was:
        tcl_deleteinterp sometimes would not return.
    Investigation revealed that an object was placed in the wrong
    bucket of the global literal table (in file tclLiteral.c). By wrong, I mean that
    the hash value of the object did not correspond tothe bucket in which
    the object appears. When this happens, the object is not successfully
    deleted and so the attempt to purge the literal table loops forever. 
    This explains why tcl_deleteinterp fails. 
    
     It turns out that the object was placed in the wrong bucket earlier, at a time
    when the hash table was rebuild (because it needed to grow in size) by
    function rebuildLiteralTable.
    This request to rebuild is called from TclRegisterLiteral.
    
    The object was inserted wrongly because, at the time of the rebuild,
    it had a null character inserted in the middle. Thus the computed
    hash value was inaccurate.
    
    The object had a null character inserted because it seems that
    routines in tclCompile.c do this at times to strings they compile.
    (I do not understand these routines very well)
    That is, these routines sometime temporarily insert nulls (saving
    the overwritten character) so that they can only look at some
    substring without the overhead of copying.  
    
    However, if a call to TclRegisterLiteral is made while this temporary
    substitution is in effect, and if this call trigges a rebuild request,
    the original object will not be hashed correctly.
    
    So, in summary,  this problem arises if the global literal table
    reaches a critical size (to trigger a rebuild) at certain points in the
    compilation process. The effects of this error (an inconsistent
    hash table, which is not, however, caught by the debugging
    checks in TclLiteral.c) cause unpredictable behaviour later, but
    for me they manifested in the failure of tcl_deleteinterp.
    
    rebuilds must occur only when all objects are in a "good" state,
    and not temporarily modified by other procedures.
    
    DesiredBehavior:
    Obviously, this is a serious bug when it strikes, and it would be nice
    to have it fixed. 
    
    I do now know Tcl or the Tcl source at all well, so it seems plausible
    to me that a similar type of error might arise for the various other
    hash tables that Tcl seems to uses internally. 
    
    Patch:
    For my own internal use, I've made a separate call
     TclRegisterLiteral_noRebuild(...) which is just like
    TclRegisterLiteral but a rebuild is not triggered even if the size limit
    is exceeded. (This seems harmless...there's surely nothing
    magic about reaching this limit and the rebuild can be deferred so long
    as we eventually get a chance to rebuild). 
     I've tried to guess at which calles in tclCompile.c should be replaced
    with this new call. This has worked for me (so far) but I really don't
    understand the code at all well, so have no confidence that I have
    really fixed this correctly and efficiently. 
    
    
    
    This is related to bug 764. (pat 10/27/98)
    
    This bug has been fixed by avoiding dangerous calls while the string is modified.
    
    
    
  4. foundin changed to: "obsolete: 8.1a2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "69. Other"
  10. title changed to:
    Hash table corruption when rebuildLiteralTable  occurs (invo
    
  11. type changed to: "Bug"