For Programmers: Free Programming Magazines  


Home > Archive > Tcl > May 2004 > compiling with TCL_MEM_DEBUG









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author compiling with TCL_MEM_DEBUG
sheila miguez herndon

2004-05-12, 9:13 pm

In the realm of ftupid questions: I downloaded the source for tcl and tk,
and compiled with TCL_MEM_DEBUG on. I checked in Tcl_Main and Tk_Main
respectively. Tk_Main supposedly calls Tcl_InitMemory if TCL_MEM_DEBUG is
defined, and Tcl_Main seems to call it regardless. Considering that, why
isn't "memory" recognized as a command when I start either a tclsh or
wish shell? I'm .

I have a wretched bug I'm trying to demolish, but I can't discuss it here
due to NDA stuff. :/

I need logging. Wish crashes due to something in my extension. I'm
betting it's a memory problem because I found some and plugged them, yet
I can still get wish to crash. I'm now reading all the Tcl C command
stuff to see what I can find.

I notice that whoever wrote the code writes to pointers that were
returned from Tcl_GetStringFromObj, and this is not supposed to be done
according to the man page (since our use doesn't fall into the
exception):

"It is passed back as a writable pointer so that extension author
creating their own Tcl_ObjType will be able to modify the string
representation within the Tcl_UpdateStringProc of their Tcl_ObjType.
Except for that limited purpose, the pointer returned by
Tcl_GetStringFromObj or Tcl_GetString should be treated as read-only. It
is recommended that this pointer be assigned to a (CONST char *)
variable."

--
sheila
Don Porter

2004-05-12, 9:13 pm

sheila miguez herndon wrote:
> In the realm of ftupid questions: I downloaded the source for tcl and tk,
> and compiled with TCL_MEM_DEBUG on. I checked in Tcl_Main and Tk_Main
> respectively. Tk_Main supposedly calls Tcl_InitMemory if TCL_MEM_DEBUG is
> defined, and Tcl_Main seems to call it regardless. Considering that, why
> isn't "memory" recognized as a command when I start either a tclsh or
> wish shell? I'm .


Perhaps your tclsh and wish programs are loading an installed
libtcl8.4.so that was not configured with TCL_MEM_DEBUG rather
than the one you configured for mem debugging, but did not install?
ldd should be able to tell you for sure.

I find that the --disable-shared configure option is my friend.

--
| Don Porter Mathematical and Computational Sciences Division |
| donald.porter@nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|_______________________________________
_______________________________|
sheila miguez herndon

2004-05-18, 3:43 pm

R. Timothy Edwards wrote in news:c7tb1c$r4j$1@aplcore.jhuapl.edu:

> Note that if the target app extends Tcl/Tk, you need to make
> sure that any use of malloc() & friends is recast to Tcl_Alloc()
> et al.; this can be done with a #define. A little more subtle is
> the use of strdup(), which stumped me for a while recently, as it
> makes an internall call to malloc() and therefore has to be
> rewritten to be used with TCL_MEM_DEBUG.
>


Shouldn't one be using ckalloc() and ckfree()?

--
sheila
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com