Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2007-06-13
02:46 • Closed ticket [219371ffff]: Incongruent def'n of Tcl_Alloc when compiled wit... artifact: d3fe2d64c6 user: hobbs
2006-03-10
23:33 • Ticket [219371ffff]: 4 changes artifact: 49e5ceecd5 user: dgp
2003-11-18
05:27 • Ticket [219371ffff]: 4 changes artifact: 97456aae3d user: dgp
2001-10-15
01:40 • Ticket [219371ffff]: 6 changes artifact: 3d7768a954 user: hobbs
2001-09-20
17:41 • Ticket [219371ffff]: 1 change artifact: 279f694d37 user: dkf
2001-02-08
21:31 • Ticket [219371ffff]: 1 change artifact: 7b7f4f5fa2 user: dkf
2000-11-15
16:37 • Ticket [219371ffff]: 6 changes artifact: 3e18b4aa81 user: dkf
2000-10-26
05:11 • New ticket [219371ffff]. artifact: 28d363c1de user: nobody

Incongruent def'n of Tcl_Alloc when compiled with TCL_MEM_DE

Closed / Out of Date219371ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 19 years ago
Descriptionplain2000-10-26 05:11:46
OriginalBugID: 5987 Bug
Version: 8.4a1
SubmitDate: '2000-07-06'
LastModified: '2000-10-25'
Severity: MED
Status: UnAssn
Submitter: techsupp
OS: All
FixedDate: '2000-10-25'
ClosedDate: '2000-10-25'


Name:
Paul Duffin

CVS:
26-Jun-2000

ObservedBehavior:
In about version 8.1 when compiled with -DTCL_MEM_DEBUG Tcl_Alloc used to be a macro which called Tcl_DbCkalloc passing the file and line number at which it was called. This changed sometime after version 8.1. There is no point in having two sets of memory allocation routines, one of which does aid
with debugging and one of which does not.

DesiredBehavior:
Tcl_Alloc should behave like ckalloc, in fact ckalloc should be deprecated in favour of Tcl_Alloc.

Patch:
Index: scriptics/tcl/generic/tcl.h
diff -c scriptics/tcl/generic/tcl.h:1.1.1.1 scriptics/tcl/generic/tcl.h:1.1.1.1.4.1
*** scriptics/tcl/generic/tcl.h:1.1.1.1Tue Jul  4 17:59:22 2000
--- scriptics/tcl/generic/tcl.hTue Jul  4 18:41:28 2000
***************
*** 1196,1210 ****
  #else /* !TCL_MEM_DEBUG */

  /*
!  * If we are not using the debugging allocator, we should call the 
!  * Tcl_Alloc, et al. routines in order to guarantee that every module
!  * is using the same memory allocator both inside and outside of the
!  * Tcl library.
   */

! #   define ckalloc(x) Tcl_Alloc(x)
! #   define ckfree(x) Tcl_Free(x)
! #   define ckrealloc(x,y) Tcl_Realloc(x,y)
  #   define Tcl_InitMemory(x)
  #   define Tcl_DumpActiveMemory(x)
  #   define Tcl_ValidateAllMemory(x,y)
--- 1196,1224 ----
  #else /* !TCL_MEM_DEBUG */

  /*
!  * There is no point in having two seperate sets of routines, ckalloc
!  * and Tcl_Alloc only one of which turns on debugging information when
!  * the TCL_MEM_DEBUG compile flag is defined. The following macros simply
!  * map ckalloc to Tcl_Alloc This reverts to Tcl 8.1 behaviour.
   */
+     
+ #define ckalloc(x) Tcl_Alloc(x)
+ #define ckfree(x) Tcl_Free(x)
+ #define ckrealloc(x,y) Tcl_Realloc(x,y)
+     
+ #ifdef TCL_MEM_DEBUG

! /*
!  * Define the Tcl_Alloc macros to supply extra debugging information
!  * to the debug memory allocator.
!  */
! 
! #   define Tcl_Alloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__)
! #   define Tcl_Free(x)  Tcl_DbCkfree(x, __FILE__, __LINE__)
! #   define Tcl_Realloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__)
! 
! #else /* !TCL_MEM_DEBUG */
! 
  #   define Tcl_InitMemory(x)
  #   define Tcl_DumpActiveMemory(x)
  #   define Tcl_ValidateAllMemory(x,y)

PatchFiles:
generic/tcl.h
dkfplain2000-11-15 16:37:41
I have to admit that I never fully understood which memory allocator routines to use, and ended up using the Tcl_* ones throughout.  It is important, however, that the Tcl_* allocator routines continue to exist in the stubs table, so that people can guarantee that their extension uses the same allocator as Tcl (apparently an issue under Windows.)
dkf Ticket [219371ffff]: 1 change [History diff]2001-02-08 21:31:39
dkf Ticket [219371ffff]: 1 change [History diff]2001-09-20 17:41:46
hobbsplain2001-10-15 01:40:15
Logged In: YES 
user_id=72656

That behavior is still in 8.3.3/8.4a3.  In fact, it looks 
like it can really be a problem if somehow Tcl is compiled 
without TCL_MEM_DEBUG but an extension is (because 
Tcl_DbCkalloc won't be defined).
dgpplain2003-11-18 05:27:31
Logged In: YES 
user_id=80530


It seems these issues may be
at the heart of what extensions
can and cannot be successfully
[load]ed into an interp.  If someone
has the dependencies sorted out,
we need them to be introspectable
at the script level for protecting against
[load]s that cannot succeed.
dgpplain2006-03-10 23:33:39
Logged In: YES 
user_id=80530

status?
hobbs Closed ticket [219371ffff]. [History diff]2007-06-13 02:46:33
Log in (anonymous is fine) to add a comment.