home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / tcl / 2253 < prev    next >
Encoding:
Internet Message Format  |  1992-12-26  |  2.2 KB

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