home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!rutgers!uwvax!cs.wisc.edu!krisna
- From: krisna@cs.wisc.edu (Krishna Kunchithapadam)
- Newsgroups: comp.lang.tcl
- Subject: Re: Tcl 6.4 Tcl_ParseVar bug OR gcc 2.2.2 bug?
- Message-ID: <krisna.725385831@cs.wisc.edu>
- Date: 26 Dec 92 16:03:51 GMT
- References: <BzMCBy.2IB7@austin.ibm.com>
- Sender: news@cs.wisc.edu (The News)
- Followup-To: comp.lang.tcl
- Organization: U of Wisconsin Madison - Computer Sciences
- Lines: 44
-
-
- Please note the Newsgroups and Followups line. I am sure the Gnu
- people have come across this problem ad-nauseum.
-
-
- madere@austin.ibm.com (Steve Madere) writes:
- :
- :When I call Tcl_Eval() repeatedly using string constants as code
- :arguments, it causes a segmentation violation. This occurs when
- :Tcl_ParseVar overwrites individual characters of my string constant
- :with a null (to mark the end of a local string) during parsing.
- :
-
- This is the crux of the problem. `gcc' stores string _constants_
- in the text segment of the `a.out' file that it creates. Hence,
- any attempt by the process (in this case Tcl_Parse()) to write
- temporary `\0' markers into these addresses *will* cause a
- segmentation fault. `gcc' has documented this in its man pages
- under the `-fwritable-strings' option, so it is more in the realm
- of a Tcl bug.
-
- Moreover, the code for Tcl_Parse() states that there are no
- side-effects, whereas, depending on your compiler, there is this
- very nasty problem.
-
-
- In my opinion, Tcl should reallocate new space for its input and
- manipulate that. With the use of gcc (and other ANSI conformant)
- compilers becoming more widespread, this problem will crop up on
- other platforms as well. Until, Tcl makes that change, I suggest
- you specify the `-fwritable-strings' (and/or the `-traditional')
- flag on the gcc compilation command line (just add it to CFLAGS
- in the Makefile) and recompile your Tcl libraries---or use
- alloced space to hold your input to the Tcl interpreter.
-
-
- Prof. Ousterhout, will this behaviour be changed in Tcl 7.0.
- Duplicating strings will be inefficient, but it will ensure
- `correctness' and will not depend on the caller's environment.
- May I also suggest that this problem be mentioned in the FAQ
- somewhere, so that it is atleast well documented.
-
-
- --Krishna
-