Artifacts Associated With Ticket 219215ffffffffff
Ticket change [fa77e1dacc] (rid 91881) by nobody on 2000-10-26 05:03:41:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized 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 - foundin initialized to: "obsolete: 8.2.2"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "69. Other"
- title initialized to: "Memory validation failure in Tcl_FindExecutable"
- type initialized to: "Bug"
Ticket change [2972edeb9f] (rid 88872) by dkf on 2001-01-31 17:35:54:
- subsystem changed to: "38. Init - Library - Autoload"
Ticket change [dc54e76137] (rid 114460) by dgp on 2001-02-08 13:55:51:
- subsystem changed to: "10. Objects"
Ticket change [acc0b9a721] (rid 101346) by andreas_kupries on 2001-09-08 06:33:18:
- assignee changed to: "msofer"
Ticket change [aeca9701cd] (rid 101699) by msofer on 2001-09-08 20:55:02:
- assignee changed to: "das"
- icomment:
Logged In: YES user_id=148712 I could not find the memory error - and didn't even try to reproduce it. However, some remarks before passing to area maintainer: The wording in the docs of should be peremptory: DO NOT change the working directory before calling Tcl_FindExecutable! The code in unix/tclUnixFile.c (TclpFindExecutable) makes clear that whenever argv[0] contains "/", the executable name "found" will be rooted at the cwd *at the time of the call to TclpFindExecutable*. So, a wrong name will be returned ... Also, the algorithm of TclpFindExecutable may be improved; it sometimes reports "correct but very ugly" results, as shown in: [mig@mini generic]$ pwd /CVS/tcl_SF_clean/generic [mig@mini generic]$ ../unix/tclsh % info nameofexecutable /CVS/tcl_SF_clean/generic/../unix/tclsh
- login: "msofer"
- mimetype: "text/plain"
- subsystem changed to: "36. Pathname Management"
- username: "msofer"
Ticket change [4ae953c0f6] (rid 126613) by msofer on 2001-09-10 03:15:05:
- icomment:
Logged In: YES user_id=148712 That last comment about what TclpFindExecutable does contains a mistake, of course. It should be: The code in unix/tclUnixFile.c (TclpFindExecutable) makesclear that whenever argv[0] contains BUT DOES NOT START WITH "/", the executable name "found" will be rooted at the cwd *at the time of the call to TclpFindExecutable*. So, a wrong name will be returned ...
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [a011dd434c] (rid 96742) by das on 2001-09-22 12:54:36:
- assignee changed to: "vincentdarley"
- icomment:
Logged In: YES user_id=90580 vince, can you take a look at this? not really my area of expertise
- login: "das"
- mimetype: "text/plain"
- username: "das"
Ticket change [074e9d103b] (rid 89374) by vincentdarley on 2001-09-24 17:27:17:
- assignee changed to: "dgp"
Ticket change [10b7b799a6] (rid 95009) by vincentdarley on 2001-09-24 17:27:18:
- icomment:
Logged In: YES user_id=32170 dgp's changes of 2001-01-04 may have fixed some issues here (When the executable is installed in or near the root directory of the file system, relative pathnames were being incorrectly generated, and in the worst case, memory access violations were crashing the program). In any case, we should definitely make sure the docs say not to change the pwd before calling Tcl_FindExecutable.
- login: "vincentdarley"
- mimetype: "text/plain"
- username: "vincentdarley"
- icomment:
Ticket change [fb3ab1f984] (rid 92016) by dgp on 2001-09-28 03:52:56:
- assignee changed to: "msofer"
- icomment:
Logged In: YES user_id=80530 I agree. This looks like a duplicate report of Bug 219416, which is fixed. The docs for Tcl_FindExecutable already say that it is "typically invoked as the very first thing in the applications main program; it must be passed argv[0] as its argument" Assigning to the Category and maintainers of doc/FileExec.3 to determine if more clarification is needed and for closing.
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Duplicate"
- subsystem changed to: "10. Objects"
- username: "dgp"
Ticket change [76d2305f7b] (rid 105648) by msofer on 2001-09-29 00:10:13:
- closedate changed to: "2001-09-28T17:10:13"
- closer changed to: "msofer"
- icomment:
Logged In: YES user_id=148712 Edited the docs to warn not to change the working directory before calling.
- login: "msofer"
- mimetype: "text/plain"
- status changed to: "Closed"
- username: "msofer"