Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2008-07-04
00:39 • Closed ticket [1987821fff]: leak in ioCmd.test plus 7 other changes artifact: 2d560df42f user: andreas_kupries
2008-07-03
23:34 • Ticket [1987821fff]: 5 changes artifact: eac05d03b2 user: dgp
23:26 • Ticket [1987821fff]: 4 changes artifact: 968a6c8b76 user: dgp
23:06 • Ticket [1987821fff]: 4 changes artifact: 6c43d211c1 user: dgp
2008-06-11
06:19 • Ticket [1987821fff]: 4 changes artifact: 3e71610d0e user: nobody
01:07 • Ticket [1987821fff]: 4 changes artifact: b3277f090f user: andreas_kupries
2008-06-10
10:29 • Ticket [1987821fff]: 4 changes artifact: 6f4d9fa7a8 user: msofer
08:58 • Ticket [1987821fff]: 4 changes artifact: eb0bcf2ca7 user: andreas_kupries
2008-06-08
02:03 • New ticket [1987821fff]. artifact: 09ebd0d20e user: msofer

leak in ioCmd.test

Closed / Fixed1987821fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2008-06-08 02:03:03
  0:  malloc (vg_replace_malloc.c:149)
  1:  TclpAlloc (tclAlloc.c:706)
  2:  Tcl_Alloc (tclCkalloc.c:1019)
  3:  Tcl_NewWideIntObj (tclObj.c:2333)
  4:  ReflectSeekWide (tclIORChan.c:1426)
  5:  Tcl_Tell (tclIO.c:6515)
  6:  Tcl_TellObjCmd (tclIOCmd.c:608)
  7:  TclEvalObjvInternal (tclBasic.c:3650)
  8:  Tcl_EvalObjv (tclBasic.c:3845)
  9:  TclEvalObjEx (tclBasic.c:4639)
-- ioCmd.test: ==11613== 170 (144 direct, 26 indirect) bytes in 6 blocks are definitely lost in loss record 6 of 6
andreas_kupriesplain2008-06-10 08:58:07
Logged In: YES 
user_id=75003
Originator: NO

That is weird. The object in line 1426 of tclIORChan.c is 'offObj', which immediately becomes the 'argOneObj' argument of 'InvokeTclMethod'. This function increments the ref-count in line 2157 of the same file, and decrements it in line 2228, same file again. The baseObj allocated after 'offObj' doesn't seem to be leaked. It goes through the same path, with code incr/decr in lines 2161 and 2230. This Tcl_Obj does not seem to leak. At least you did not say anything about that.

It is not clear to me how one of the two leaks, but not the other.

Can you tell me how you invoked valgrind, your test script, and so on to help me in investigating this ?

Note that the new tclIORTrans.c has an identical InvokeTclMethod which may be susceptible as well, depending.
msoferplain2008-06-10 10:29:41
Logged In: YES 
user_id=148712
Originator: YES

Right - weird indeed. In a build of today's HEAD configured as
  CFLAGS=-DPURIFY ./configure --disable-shared --enable-symbols
tcltest shows the leak, but tclsh does not! Specifically
  /usr/bin/valgrind --leak-check=yes --show-reachable=yes --num-callers=10 ./tcltest ../tests/ioCmd.test
has it, but not
  /usr/bin/valgrind --leak-check=yes --show-reachable=yes --num-callers=10 ./tclsh ../tests/ioCmd.test
andreas_kupriesplain2008-06-11 01:07:31
Logged In: YES 
user_id=75003
Originator: NO

Has tcltest a special mem allocator which could cause this ?
[email protected]plain2008-06-11 06:19:00
Logged In: NO 

Not that I know of. Here in both cases the -DPURIFY should enact the direct-malloc obj allocator, which should be synchronous.

Could you attach to the process near the end to look at the final refcount (assume 1 but who knows ?) ?
dgpplain2008-07-03 23:06:44
Logged In: YES 
user_id=80530
Originator: NO


The difference between tclsh and tcltest
is most likely due to the availability
of more testing commands in tcltest,
which disables more constraints which
runs more tests.  The leaking code is
probably not even run in tclsh.
dgpplain2008-07-03 23:26:21
Logged In: YES 
user_id=80530
Originator: NO


leak is in test iocmd-32.0
dgpplain2008-07-03 23:34:45
Logged In: YES 
user_id=80530
Originator: NO


line 2132 of Revision 1.33 of
tclIORChan.c permits an early
return from InvokeTclMethod()
which doesn't tend to refcount
maintenace on the argument
Tcl_Obj's passed in.  Fix that,
and this bug will be repaired.

Now in the maintainer's hands.
andreas_kupriesplain2008-07-04 00:39:39
Logged In: YES 
user_id=75003
Originator: NO

Fixed in head and 8.5 branch.
Log in (anonymous is fine) to add a comment.