View Ticket
Not logged in
2016-02-05
19:07 Closed ticket [cf74deb33c]: OO leaks plus 6 other changes artifact: 8a64dd8da6 user: dgp
2016-02-04
21:05 Ticket [cf74deb33c]: 3 changes artifact: e2f6bd54a8 user: dgp
21:05
[cf74deb33c] Plug memleaks in class teardown. check-in: 4bb95ffc51 user: dgp tags: trunk
10:03 Ticket [cf74deb33c] OO leaks status still Open with 4 other changes artifact: 1b41fb1196 user: dkf
2016-02-03
13:00 Ticket [cf74deb33c]: 3 changes artifact: 7f29373e84 user: dgp
2016-02-02
20:08 Ticket [cf74deb33c]: 3 changes artifact: a78e3dfefb user: dgp
18:55 Ticket [cf74deb33c]: 3 changes artifact: ace6dcba24 user: dgp
18:54 Ticket [cf74deb33c]: 3 changes artifact: 46b2ebd092 user: dgp
12:50 Ticket [cf74deb33c]: 3 changes artifact: 7b226f4a6e user: dgp
2016-02-01
23:43 Ticket [cf74deb33c]: 3 changes artifact: a1e0f1146c user: msofer
23:07 Ticket [cf74deb33c]: 4 changes artifact: ceaf69bf31 user: dkf
23:06 Ticket [cf74deb33c]: 4 changes artifact: b5cb7ba48a user: dkf
2016-01-31
23:55 Ticket [cf74deb33c]: 3 changes artifact: b4eded59d6 user: dgp
05:55 Ticket [cf74deb33c]: 3 changes artifact: 958a2c935c user: msofer
05:55 New ticket [cf74deb33c]. artifact: 97515b46b4 user: msofer

Ticket UUID: cf74deb33c88d391fe9028b58cdfe264b9b300d4
Title: OO leaks
Type: Bug Version: trunk
Submitter: msofer Created on: 2016-01-31 05:55:10
Subsystem: 35. TclOO Package Assigned To: dgp
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2016-02-05 19:07:49
Resolution: Fixed Closed By: dgp
    Closed on: 2016-02-05 19:07:49
Description:
Valgrind found two leaks triggered by oo.test and ooNext.test. Stack traces are:

mig@X13:~/DEVEL/tcl-core/trunk/unix$ cat ERR.leaks 
Leak #1
  0:  malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  1:  TclpAlloc (tclAlloc.c:699)
  2:  Tcl_Alloc (tclCkalloc.c:1059)
  3:  AllocClass (tclOO.c:1539)
  4:  TclNRNewObjectInstance (tclOO.c:1790)
  5:  TclOO_Class_Create (tclOOBasic.c:198)
  6:  TclOOInvokeContext (tclOOCall.c:309)
  7:  TclOOObjectCmdCore (tclOO.c:2635)
  8:  PublicNRObjectCmd (tclOO.c:2451)
  9:  Dispatch (tclBasic.c:4353)
-- oo.test: ==26247== 832 (528 direct, 304 indirect) bytes in 2 blocks are definitely lost in loss record 3 of 4

Leak #2
  0:  malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  1:  TclpAlloc (tclAlloc.c:699)
  2:  Tcl_Alloc (tclCkalloc.c:1059)
  3:  AllocObject (tclOO.c:568)
  4:  TclNRNewObjectInstance (tclOO.c:1773)
  5:  TclOO_Class_Create (tclOOBasic.c:198)
  6:  TclOOInvokeContext (tclOOCall.c:309)
  7:  TclOOObjectCmdCore (tclOO.c:2635)
  8:  PublicNRObjectCmd (tclOO.c:2451)
  9:  Dispatch (tclBasic.c:4353)
-- ooNext2.test: ==26246== 832 (304 direct, 528 indirect) bytes in 2 blocks are definitely lost in loss record 2 of 2
-- oo.test: ==26247== 1,248 (456 direct, 792 indirect) bytes in 3 blocks are definitely lost in loss record 4 of 4
User Comments: dgp added on 2016-02-04 21:05:08:
committing patch to trunk that stops the identified leaks
in the test suite.

dkf added on 2016-02-04 10:03:10:

The deletion code is by far the trickiest place in TclOO. It's particularly compounded by the way that oo::object and oo::class cross-reference themselves and each other. I strongly recommend only doing testing with --enable-symbols=mem enabled, as that catches a much higher proportion of bad behaviour (because it scribbles over memory when it releases).


dgp added on 2016-02-03 13:00:46:
Clear that the trouble lies in the refcount dance
found in ReleaseClassContents(). These things
are always tricky.

Refcounts for several objects found on lists
are bumped near the start.  Seems that these
objects get taken odd the lists before another
pass through the lists decrementing the refcounts
is supposed to free them.

dgp added on 2016-02-02 20:08:38:
Bisecting shows that at least the oo-14.7 leak
arrives with checkin

http://core.tcl.tk/tcl/info/9a6b1363308cade8

dgp added on 2016-02-02 18:55:33:
Likely suspect: inheritance and mixins.

dgp added on 2016-02-02 18:54:12:
dgp	oo.test leaks in oo-14.[678]

dgp	ooNext2.test leaks in oo-call-1.2[01]

dgp added on 2016-02-02 12:50:54:
Use the TCLTEST_OPTIONS env variable to govern the
valgrind with tcltest package options.  Useful ones
for narrowing causes are -file -match -verbose -skip

I also advise check pre- and post- each of the bugfixes
I mentioned before.  Knowing the patch that's bad can
be as useful as knowing the test that triggers.

msofer added on 2016-02-01 23:43:40:
There is AFAIK no simple way to determine which test triggers the leak, as valgrind will (can?) only analyze the leaks on process shutdown. I guess one would have to run each test separately under valgrind.

dkf added on 2016-02-01 23:07:35:

(i.e., we are leaking classes, not normal instances.)


dkf added on 2016-02-01 23:06:22:

Those are very unspecific traces; they just tell me that the objects were allocated using oo::class create. Any chance of narrowing down which tests trigger the leaks?


dgp added on 2016-01-31 23:55:51:
Likely suspects are

http://core.tcl.tk/tcl/tktview?name=593baa032c

and

http://core.tcl.tk/tcl/tktview?name=3d96b7076e