Problems with caching of resolution of [my init]
Closed / Accepted1959637fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 18 years ago
Descriptionplain2008-05-07 16:32:22
This problem has proven difficult to reduce to a small test case; there is a certain Heisenbug aspect to it.
I do have a large case that is consistently failing, though, so that's part of the battle. (And in any case, I'd like to have some of what I've done for TDBC to be tested by someone other than me.)
I have a development snapshot of TDBC located at
http://kbk.is-a-geek.net:2301/zip/6647a04e19.zip
To reproduce the problem:
(1) Build and install the Tcl HEAD, the Tk HEAD,
and the TclOO HEAD. (Win32 MinGW+msys build
preferred; I've not tested any other toolchain.)
(2) Configure and make the 'tdbc' project in the
supplied archive.
(3) Configure, make, and test the 'tdbcodbc' project.
All tests are expected to pass.
(4) Change the string 'init2' at line 460 of
tdbcodbc/generic/tdbcodbc.c and at line
195 of tdbcodbc/library/tdbcodbc.tcl to
read simply 'init'.
(5) Make and test again. Now several tests fail.
The problem appears to be that the call to
[my init] in the constructor of
tdbc::odbc::statement actually arrives into
the [init] method of tdbc::odbc::typesStatement.
The behaviour is strongly dependent on
context; the test cases in question continue
to pass when run in isolation.
dkf informs me that he suspects that overaggressive
caching (or indolent clearing of the cache) relating
to [my] is the culprit, but asked for a test case.
Alas, I've been at a loss to reduce this to a small
one.
kennykbplain2008-05-11 09:56:20
Logged In: YES
user_id=99768
Originator: YES
I've been able to reproduce the problem in tdbcsqlite3, and
hence eliminate the nasty ODBC dependencies that are otherwise
there. (I've also moved forward to the HEAD of tcloo as of
2008-05-10)
If you download the baseline:
http://kbk.is-a-geek.net:2301/zip/e659cb3857.zip
then build and install tdbc (note that it is changed since
the lase baseline!), and finally do
cd tdbcsqlite3
tclsh8.6 tempTest.tcl -match tdbcsqlite3-9.[123] -verbose btefp
you'll see that tdbcsqlite3-9.3 fails. If instead you do
tclsh8.6 tempTest.tcl -match tdbcsqlite3-9.3 -verbose btefp
you'll see that tdbcsqlite3-9.3 succeeds in isolation.
Note that there's no need to edit code; I haven't yet
been able to rewrite the affected methods to *not* trip
over the resolution issues.
To see what's being resolved, of course, you *can* edit
code. In tdbc/library/tdbc.tcl, comment out the line
near the top of the file that looks like:
proc tdbc::puts args {}
and it will give you a little bit of dribble tracing the
path through several of the methods. What appears to be
happening is that tdbc::connection::foreach is invoking
$stmt foreach
where $stmt is an instance of tdbc::sqlite3::statement
(which inherits from tdbc::statement).
But the method that we actually arrive at is
tdbc::resultset::foreach - as demonstrated by the printouts:
Entering ::tdbc::connection::foreach
Class == ::tdbc::connection
Instance == ::db
Call == db foreach row {
SELECT idnum, name FROM people WHERE name LIKE 'b%'
} {
lappend result $row
}
Entering ::tdbc::resultset::foreach
Class == ::tdbc::resultset
Call == ::oo::Obj9::Stmt::5 foreach -as dicts -- row {
lappend result $row
}
and from thence it jumps the tracks completely.
This is at least a shorter sequence to go on; sorry that
I still am having trouble paring it down.
I'm also bumping the priority, since this bug is seriously
hampering tdbc development.
kennykbplain2008-05-11 09:59:22
Logged In: YES user_id=99768 Originator: YES Sorry, I miscopied the URL for the baseline to test: It should have been http://kbk.is-a-geek.net:2301/zip/555c15831d.zip
kennykbplain2008-05-12 08:20:47
Logged In: YES user_id=99768 Originator: YES Against todays HEAD of tclOO, all tests that I expect to pass are passing on Ubuntu, while crashing on Windows with a panic "expected to create new entry for object map" dkf advised me that Valgrind output is necessary for the next round of bug-hunting, and indeed even the Ubuntu version (which appears to run "normally" has a read of freed storage (first appearing in tdbcsqlite3-1.4). The stack traces that Valgrind is reporting are ==3378== ==3378== Invalid read of size 4 ==3378== at 0x4F9AF8A: TclOOGetCallContext (tclOOCall.c:680) ==3378== by 0x4F97D53: TclOOObjectCmdCore (tclOO.c:1903) ==3378== by 0x4F979FE: PrivateObjectCmd (tclOO.c:1800) ==3378== by 0x404F1EA: TclEvalObjvInternal (tclBasic.c:3645) ==3378== by 0x40AD0EA: TclExecuteByteCode (tclExecute.c:2327) ==3378== by 0x4119AA6: TclObjInterpProcCore (tclProc.c:1721) ==3378== by 0x4FA306B: InvokeProcedureMethod (tclOOMethod.c:730) ==3378== by 0x4F9A768: TclOOInvokeContext (tclOOCall.c:219) ==3378== by 0x4F966A7: Tcl_NewObjectInstance (tclOO.c:1243) ==3378== by 0x4F98180: ClassCreate (tclOO.c:2034) ==3378== by 0x4FA261A: BasicMethodInvoke (tclOOMethod.c:323) ==3378== by 0x4F9A768: TclOOInvokeContext (tclOOCall.c:219) ==3378== Address 0x53528C4 is 76 bytes inside a block of size 116 free'd ==3378== at 0x402237F: free (vg_replace_malloc.c:233) ==3378== by 0x404A987: TclpFree (tclAlloc.c:729) ==3378== by 0x405725A: Tcl_DbCkfree (tclCkalloc.c:633) ==3378== by 0x411701C: Tcl_Release (tclPreserve.c:230) ==3378== by 0x4F94BBC: ObjectRenamedTrace (tclOO.c:582) ==3378== by 0x404E11F: CallCommandTraces (tclBasic.c:2914) ==3378== by 0x404DDC0: Tcl_DeleteCommandFromToken (tclBasic.c:2737) ==3378== by 0x404D553: TclRenameCommand (tclBasic.c:2238) ==3378== by 0x40680A5: Tcl_RenameObjCmd (tclCmdMZ.c:858) ==3378== by 0x404F1EA: TclEvalObjvInternal (tclBasic.c:3645) ==3378== by 0x40AD0EA: TclExecuteByteCode (tclExecute.c:2327) ==3378== by 0x40AA545: TclCompEvalObj (tclExecute.c:1473)
dkfplain2008-05-12 16:54:00
Logged In: YES user_id=79902 Originator: NO Now that was helpful, it's the first real lead on this problem I've had. In particular, it tells me that the code to figure out whether there cached context was referring to the wrong object was not taking account of the fact that an object can be deleted! Easiest fix is to store a copy of the object creation epoch in the context. I hope this fixes things...
dkf Ticket [1959637fff]: 1 change
[History diff]2008-05-12 16:54:01
dkf Pending ticket [1959637fff].
[History diff]2008-05-15 14:56:09
sf-robotplain2008-05-30 09:20:22
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).
sdeaseyplain2008-11-22 04:00:34
I don't think this bug is fixed.
Ticket was closed 2008-05-30, and tcl-8.5.5 was released 2008-10-15.
I'm experiencing this (or a very similar bug) with tcl8.5.5.
It occurs very early in the startup of naviserver.
Here's a backtrace:
Fatal: expected to create new entry for object map
#0 0x00110416 in __kernel_vsyscall ()
#1 0x00b42660 in raise () from /lib/libc.so.6
#2 0x00b44028 in abort () from /lib/libc.so.6
#3 0x00144f18 in Panic (fmt=0x2b0760 "expected to create new entry for object map") at log.c:617
#4 0x0025fec7 in Tcl_PanicVA (format=0x2b0760 "expected to create new entry for object map",
argList=0xbfd92824 "") at /home/sd/src/tcl8.5.5/unix/../generic/tclPanic.c:93
#5 0x0025ffca in Tcl_Panic (format=0x2b0760 "expected to create new entry for object map")
at /home/sd/src/tcl8.5.5/unix/../generic/tclPanic.c:132
#6 0x0025c7b6 in TclDbInitNewObj (objPtr=0x95f1220) at /home/sd/src/tcl8.5.5/unix/../generic/tclObj.c:637
#7 0x0024b919 in Tcl_DbNewListObj (objc=1, objv=0xbfd92890,
file=0x2ac234 "/home/sd/src/tcl8.5.5/unix/../generic/tclFileName.c", line=787)
at /home/sd/src/tcl8.5.5/unix/../generic/tclListObj.c:239
#8 0x00227d72 in Tcl_FSJoinToPath (pathPtr=0x961eb50, objc=0, objv=0x0)
at /home/sd/src/tcl8.5.5/unix/../generic/tclFileName.c:787
#9 0x0026639d in SetFsPathFromAny (interp=0x0, pathPtr=0x961eb50)
at /home/sd/src/tcl8.5.5/unix/../generic/tclPathObj.c:2441
#10 0x00265e4b in TclFSSetPathDetails (pathPtr=0x961eb50, fsRecPtr=0x95ee640, clientData=0x0)
at /home/sd/src/tcl8.5.5/unix/../generic/tclPathObj.c:2203
#11 0x0024a1c3 in Tcl_FSGetFileSystemForPath (pathPtr=0x961eb50)
at /home/sd/src/tcl8.5.5/unix/../generic/tclIOUtil.c:4437
#12 0x00248a63 in Tcl_FSGetCwd (interp=0x0) at /home/sd/src/tcl8.5.5/unix/../generic/tclIOUtil.c:2736
#13 0x00148603 in SetCwd (path=0x962f3c8 "/home/sd/ns-scratch-hg/tests") at nsmain.c:1063
#14 0x00147c24 in Ns_Main (argc=8, argv=0xbfd92d04, initProc=0x8048636 <ServerInit>) at nsmain.c:504
#15 0x0804862c in main (argc=Cannot access memory at address 0x5785
) at main.c:64
You can browse the source for nsmain.c here:
http://www.bitbucket.org/naviserver/naviserver/src/tip/nsd/nsmain.c
You can reproduce by grabbing this snapshot tarball:
http://www.bitbucket.org/naviserver/naviserver/get/5e395980f472.gz
building, and running the tests. There are no other dependencies.
This works for me on tcl8.4.19. Linux 2.6.26, glibc-2.8, 32 bit (Fedora 9).
Any tips?
dkfplain2008-11-22 05:19:24
That's entirely unrelated. TclOO does not work with 8.4 at all, and nor is it involved in that trace. Raise another issue if you want, but we won't track this in this item any more.
Log in (anonymous is fine) to add a comment.