Tiago Dionizio wrote:

Using: SQLite 3 from cvs Fedora Core 2 gcc 3.3.3

I am currently working on trying to bind sqlite3 to Lua, and
while testing things i encountered some problems regarding
uninitialised values in the sqlite library.

These tests were done using user defined functions, and more
specifically, when using aggregate functions.

This is a stack trace from valgrind with the problem i found
on my lua tests:

==9321== Conditional jump or move depends on uninitialised value(s)
==9321==    at 0x1BA6E8FB: sqlite3VdbeMemRelease (vdbemem.c:185)
==9321==    by 0x1BA6ED48: sqlite3VdbeMemSetStr (vdbemem.c:372)
==9321==    by 0x1BA6ADAF: sqlite3_result_text (vdbeapi.c:101)
==9321==    by 0x1BA5F77D: lcontext_result (lsqlite3.c:814)
==9321==    by 0x1B910083: luaD_precall (ldo.c:260)
==9321==    by 0x1B91AB45: luaV_execute (lvm.c:627)
==9321==    by 0x1B9103A1: luaD_call (ldo.c:313)
==9321==    by 0x1B90C69E: f_call (lapi.c:672)
==9321==    by 0x1B90F927: luaD_rawrunprotected (ldo.c:88)
==9321==    by 0x1B91089D: luaD_pcall (ldo.c:416)
==9321==    by 0x1B90C6F9: lua_pcall (lapi.c:685)
==9321==    by 0x1BA6010D: db_sql_finalize_function (lsqlite3.c:1058)
==9321==    by 0x1BA99783: sqlite3VdbeExec (vdbe.c:4363)

The value that valgrind claims is uninitialized at vdbemem.c:185 is clearly initialized to MEM_Null on vdbe.c:4357, 6 lines above the call to db_sql_finalize_function. It appears that somewhere in the chain of 8 intermediate LUA calls the sqlite_context* pointer is begin corrupted somehow.


==9305== Conditional jump or move depends on uninitialised value(s) ==9305== at 0x80528FB: sqlite3_aggregate_context (vdbeapi.c:190) ==9305== by 0x8048E69: udf1_scalar (test.c:72) ==9305== by 0x807C31A: sqlite3VdbeExec (vdbe.c:1175) ==9305== by 0x8052899: sqlite3_step (vdbeapi.c:159) ==9305== by 0x8048D77: do_query (test.c:51) ==9305== by 0x8049240: main (test.c:142)

i tried to make the test case as similar as possible as it would go
on the lua script. (file attached)

I have no idea where to look for, and believe this is an issue with
sqlite, if i am using the functions correctly.


Udf1_scalar is a scalar function (not an aggregate function) and scalar functions should never call sqlite3_aggregate_context(). This is an error in test1.c, not in SQLite. You might argue that SQLite could do a better job of detecting this kind of programmer error on the part of the calling application, and you would be right. But technically, it is not a problem in SQLite.

--
D. Richard Hipp -- [EMAIL PROTECTED] -- 704.948.4565



Reply via email to