Segfault on increasing and descreasing refcounter for Dict
Closed / Invalid1879097fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2008-01-24 19:23:15
The following program segfaults (Tcl 8.5.0 on Debian GNU/Linux, also checked on 8.5b3, doesn't work either):
% cat test.c
#include <stdio.h>
#include <tcl.h>
void
refcount_test (const char *fname, Tcl_Obj *o)
{
printf ("%s () => %p\n", fname, o);
fputs ("trying Tcl_IncrRefCount (), Tcl_DecrRefCount ()... ", stdout);
fflush (stdout);
Tcl_IncrRefCount (o);
Tcl_DecrRefCount (o);
fputs ("done\n", stdout);
}
int
main ()
{
refcount_test ("Tcl_NewObj",
Tcl_NewObj ());
refcount_test ("Tcl_NewIntObj",
Tcl_NewIntObj (123));
refcount_test ("Tcl_NewStringObj",
Tcl_NewStringObj ("test", -1));
refcount_test ("Tcl_NewDictObj",
Tcl_NewDictObj ());
/* . */
return 0;
}
% make CFLAGS=-g\ -Wall\ -I/usr/include/tcl8.5 test LDFLAGS=-ltcl8.5
The output is:
% ./test
Tcl_NewObj () => 0x804a2f8
trying Tcl_IncrRefCount (), Tcl_DecrRefCount ()... done
Tcl_NewIntObj () => 0x804a2f8
trying Tcl_IncrRefCount (), Tcl_DecrRefCount ()... done
Tcl_NewStringObj () => 0x804a2f8
trying Tcl_IncrRefCount (), Tcl_DecrRefCount ()... done
Tcl_NewDictObj () => 0x804a2f8
trying Tcl_IncrRefCount (), Tcl_DecrRefCount ()... zsh: segmentation fault (core dumped) ./test
The backtrace is:
% gdb -c core test
......
(gdb) bt
#0 0x00000000 in ?? ()
#1 0xf7f52249 in ThreadStorageGetHashTable (id=0xf7d008e0)
at /home/sergei/debian/tcl-pkg/build-area/tcl8.5-8.5.0/unix/../generic/tclThreadStorage.c:212
#2 0xf7f5239a in TclpThreadDataKeyGet (keyPtr=0xf7f9473c)
at /home/sergei/debian/tcl-pkg/build-area/tcl8.5-8.5.0/unix/../generic/tclThreadStorage.c:336
#3 0xf7f50756 in Tcl_GetThreadData (keyPtr=0xf7f9473c, size=8)
at /home/sergei/debian/tcl-pkg/build-area/tcl8.5-8.5.0/unix/../generic/tclThread.c:87
#4 0xf7f3157a in TclFreeObj (objPtr=0x804a2f8)
at /home/sergei/debian/tcl-pkg/build-area/tcl8.5-8.5.0/unix/../generic/tclObj.c:911
#5 0x08048694 in refcount_test (fname=0x80488d1 "Tcl_NewDictObj", o=0x804a2f8) at test.c:12
#6 0x08048736 in main () at test.c:25
The original bug report in Debian BTS is available at http://bugs.debian.org/462409
mistachkinplain2008-01-25 03:32:56
Logged In: YES user_id=113501 Originator: NO This appears to be caused by the thread storage subsystem not having been initialized. A call to Tcl_FindExecutable function in main() prior to calling any other Tcl C API functions should fix the problem.
dkf Pending ticket [1879097fff].
[History diff]2008-01-29 21:21:41
sf-robotplain2008-02-14 00:44:01
Logged In: YES user_id=1312539 Originator: NO This Tracker item was closed automatically by the system. It was previously set to a Pending status, and the original submitter did not respond within 14 days (the time period specified by the administrator of this Tracker).
Log in (anonymous is fine) to add a comment.