Ticket UUID: | f50ff6f929119c62f9994d974a69be5e8bbf52d0 | |||
Title: | memory command is not available with TCL_MEM_DEBUG enabled libraries | |||
Type: | Bug | Version: | 8.4.9.1 | |
Submitter: | sakthivp | Created on: | 2014-03-11 07:19:07 | |
Subsystem: | 41. Memory Allocation | Assigned To: | dgp | |
Priority: | 5 Medium | Severity: | Critical | |
Status: | Closed | Last Modified: | 2014-03-11 17:25:28 | |
Resolution: | Invalid | Closed By: | dgp | |
Closed on: | 2014-03-11 17:25:28 | |||
Description: |
I compiled the Tcl libraries with TCL_MEM_DEBUG symbol by configuring using below command. ./configure --prefix=/scratch/sakthi/Tcl_8.4.9_debug --enable-symbols=all I found a library with name libtcl8.4g.so. Then i wrote a C program which uses the debug shared object to invoke Tcl 'memory' command. The program failed to execute the 'memory' command. C program --------- #include <stdio.h> #include <tcl.h> #include <stdio.h> #include <tcl.h> int main() { int x=0; Tcl_Interp* a; a = Tcl_CreateInterp(); Tcl_Init(a); Tcl_InitMemory(a); if (a == NULL) printf("Interpreter creation Failed \n"); x = Tcl_Eval(a,(char *)"memory info"); Tcl_DeleteInterp(a); printf("DeleteInterpreter x=%d \n",x); } --------------------- Compilation flags on solaris10 server /opt/Studio11/SUNWspro/bin/CC -L/scratch/sakthi/Tcl_8.4.9_debug/lib -ltcl8.4g -I/scratch/sakthi/Tcl_8.4.9_debug/include Tcl_inter_problem.c -o Tcl_inter_problem ---------------------- Output of the program DeleteInterpreter x=1 // Tcl_Eval function returns 1 (TCL_ERROR), unable to execute memory command. I have attached the Makefile which was generated by configure script. | |||
User Comments: |
dgp added on 2014-03-11 17:24:46:
You must place the #define TCL_MEM_DEBUG before the *first* (why do you have more than one?) #include <tcl.h> for it to have effect. sakthivp added on 2014-03-11 14:22:28: After adding '#define TCL_MEM_DEBUG' i compiled the program with -ltcl8.4g. But the output of the program is same. ----------- #include <stdio.h> #include <tcl.h> #include <stdio.h> #define TCL_MEM_DEBUG #include <tcl.h> int main() { int x=0; Tcl_Interp* a; a = Tcl_CreateInterp(); Tcl_Init(a); Tcl_InitMemory(a); if (a == NULL) printf("Interpreter creation Failed \n"); x = Tcl_Eval(a,(char *)"memory info"); Tcl_DeleteInterp(a); printf("DeleteInterpreter x=%d \n",x); } ---------------------- compilation /opt/Studio11/SUNWspro/bin/CC -L/scratch/sakthi/Tcl_8.4.9_debug/lib -ltcl8.4g -I/scratch/sakthi/Tcl_8.4.9_debug/include Tcl_inter_problem.c -o ----------------------- output of the program: Tcl_inter_problem DeleteInterpreter x=1 ------------------------ Tcl8.6 Library ============== I compiled the Tcl8.6 source code with TCL_MEM_DEBUG flag (attached the config.log), but there was no libtcl8.6g.so libraries. I linked the library with my program and found the same result with 8.6 libraries. /opt/Studio11/SUNWspro/bin/CC -L/scratch/sakthi/Tcl_8.6_debug_2/lib -ltcl8.6 -I/scratch/sakthi/Tcl_8.6_debug_2/include Tcl_inter_problem.c -o Tcl_inter_problem output ------ Tcl_inter_problem DeleteInterpreter x=1 Can you please help me on this? dgp added on 2014-03-11 13:53:59: I got curious enough to look. Your error is a simple one. You forgot to #define TCL_MEM_DEBUG when compiling your program. One simple way to correct this is just to add it in your program source code: #include <stdio.h> #define TCL_MEM_DEBUG #include <tcl.h> int main() { int x=0; Tcl_Interp* a; a = Tcl_CreateInterp(); Tcl_Init(a); Tcl_InitMemory(a); if (a == NULL) printf("Interpreter creation Failed \n"); x = Tcl_Eval(a,(char *)"memory info"); Tcl_DeleteInterp(a); printf("DeleteInterpreter x=%d \n",x); } If you need more flexible configuration options than that, I'll leave the use of -DTCL_MEM_DEBUG in your build machinery as an exercise. Now please update your Tcl. If you really, really truly cannot leave Tcl 8.4, at least move to Tcl 8.4.20 so you stop ignoring 9 years of bug fixes. dgp added on 2014-03-11 13:06:05: We no longer support Tcl 8.4. Do you see any similar problems using Tcl 8.5.15? |