Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: fa77e1dacc1b7bdf7279f1355e3b12f43a2634bc
Ticket: 219215ffffffffffffffffffffffffffffffffff
Memory validation failure in Tcl_FindExecutable
User & Date: nobody on 2000-10-26 05:03:41
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 3863 Bug
    Version: 8.2.2
    SubmitDate: '1999-12-13'
    LastModified: '2000-04-03'
    Severity: MED
    Status: Assigned
    Submitter: techsupp
    ChangedBy: hobbs
    OS: Solaris
    OSVersion: 2.6
    Machine: Sparc 5
    FixedDate: '2000-10-25'
    ClosedDate: '2000-10-25'
    
    
    Name: John R. Jackson
    
    Comments:
    A word of advice (and maybe it will save you all the time it took me to figure out :-): if you run this
    under gdb, it messes with argv[0] and uses a full path which does not trip the bug. In that case,
    tweak the test case to pass an explicit value, e.g. "./bug".
    
    ReproducibleScript:
    Run the following example **exactly** like this against Tcl built with TCL_MEM_DEBUG:
    
      ./a.out /
    
    #include <unistd.h>
    #include <tcl.h>
    
    int
    main (argc, argv)
            int                     argc;
            char                    **argv;
    {
            if (argc > 1) {
                    (void) chdir(argv[1]);
            }
            Tcl_FindExecutable(argv[0]);
            return 0;
    }
    
    If the program is called without the ./ it works.
    If the program is called without arguments (so it does not chdir), it works.
    If the program is called with an argument other than /opt (e.g. /foozle), it works.
    
    ObservedBehavior:
    low guard byte 4 is 0xef         
    low guard byte 5 is 0xff         
    low guard byte 6 is 0xe7         
    low guard byte 7 is 0xe0         
    total mallocs                     34
    total frees                        1
    current packets allocated         33
    current bytes allocated         1483
    maximum packets allocated         33
    maximum bytes allocated         1483
    low guard failed at 230d0, ./../unix/tclUnixInit.c 327
    20 bytes allocated at (./../generic/tclFileName.c 381)
    Memory validation failure
    Abort
    
    DesiredBehavior:
    My application tries to cd to a "safe" place as soon as possible to protect any core files that are
    generated (not that my code would ever do that, of course :-), and this was done before the Tcl_FindExecutable call. After reading the man page again and stepping through the code to try
    and find the problem (but I got tired and gave up), I can see that I should probably call Tcl_FindExecutable immediately on entry, which is OK. But there is still pretty clearly something
    wrong in the guts of this thing -- it shouldn't trip a memory fault.
    
    
    
    Verified with 8.3.0.  You can work-around it with:
    
            if (argc > 1) {
                    (void) chdir(argv[1]);
              Tcl_FindExecutable(argv[1]);
            } else {
              Tcl_FindExecutable(argv[0]);
            }
            return 0;
    
    Or doing the FindExecutable first. 
    -- 04/03/2000 hobbs
    
  4. foundin changed to: "obsolete: 8.2.2"
  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: "Memory validation failure in Tcl_FindExecutable"
  11. type changed to: "Bug"