Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] db/gdbm rewrite



On Wed, 15 Feb 2017 02:22:43 -0800
Sebastian Gniazdowski <psprint2@xxxxxxxxxxxx> wrote:
> Changes:
> – data is (un)metafied – compatibility with normal database usage
> – new parameter "zgdbm_tied", array holding tied parameters' names
> – new builtin "zgdmpath", returning ($REPLY) path to database file, of
> given tied parameter
> – new tests (Unicode, metafication, new parameter)
> – updated documentation
> 
> Original db_gdbm was a no-go because it sucked widget names into
> database:
> 
> https://asciinema.org/a/12ffm5ltpj9udnmradtat17am
> 
> Current db_gdbm is a no-go because GDBM doesn't always return \0
> terminated strings.. Sorry for that, but the update solves this.
> 
> I sent is as patch, plus the new file (as option, patch includes)
> Test/V11db_gdbm.ztst.

Thanks.

I've fixed the following warnings (which are trivial).

I'm also getting a test failure from allocation.  My gdbm is quite old,
1.8.3, but it also looks like I have --enable-zsh-mem, which you don't,
as well as --enable-zsh-debug, so the difference is more likely to be
that.  Just running the test code on its own is enough to show it up.

The error from the debug  is on the line

dbase[testkey]=testdata

I've added the stack trace; the key context will be frame 2: it's the
first zsfree() in gdbmsetfn().  Is it simply counting of terminating
'\0's again, or should it not actually be treating the data as a
string at all?

pws

db_gdbm.c: In function ‘bin_zgdbmpath’:
db_gdbm.c:231:15: warning: unused variable ‘reply_pm’ [-Wunused-variable]
     Param pm, reply_pm;
               ^~~~~~~~
db_gdbm.c: In function ‘scangdbmkeys’:
db_gdbm.c:437:16: warning: unused variable ‘content’ [-Wunused-variable]
     datum key, content;
                ^~~~~~~
db_gdbm.c:436:11: warning: unused variable ‘pm’ [-Wunused-variable]
     Param pm = NULL;
           ^~

% make TESTNUM=V11 ZTST_verbose=1
if test -n "gcc"; then \
  cd .. && DESTDIR= \
  make MODDIR=`pwd`/Test/Modules install.modules > /dev/null; \
fi
if ZTST_testlist="`for f in ./V11*.ztst; \
           do echo $f; done`" \
 ZTST_srcdir="." \
 ZTST_exe=../Src/zsh \
 ../Src/zsh +Z -f ./runtests.zsh; then \
 stat=0; \
else \
 stat=1; \
fi; \
sleep 1; \
rm -rf Modules .zcompdump; \
exit $stat
./V11db_gdbm.ztst: starting.
Running test: unload and reload the module without crashing
Test successful.
Running test: create the database
Test successful.
Running test: open the database read-only
Test successful.
Running test: store key in database
--- /tmp/zsh.ztst.19816/ztst.err	2017-02-16 09:58:41.220556989 +0000
+++ /tmp/zsh.ztst.19816/ztst.terr	2017-02-16 09:58:41.258558381 +0000
@@ -0,0 +1 @@
+6: mem.c:1512: BUG: attempt to free more than allocated.
Test ./V11db_gdbm.ztst failed: error output differs from expected as shown above for:
 ztie -d db/gdbm -f $dbfile dbase
 dbase[testkey]=testdata
 zuntie dbase
 ztie -r -d db/gdbm -f $dbfile dbase
 echo $dbase[testkey]
 zuntie -u dbase
Was testing: store key in database
./V11db_gdbm.ztst: test failed.
**************************************
0 successful test scripts, 1 failure, 0 skipped
**************************************
make: *** [check] Error 1

#0  zfree (p=0x8733c30, sz=0) at mem.c:1512
#1  0x080a4ce4 in zsfree (p=0x8733c30 "testdata\030<s\b\377\377\377\377H<s\b\377\377\377\377P<s\b\377\377\377\377h<s\b\377\377\377\377dbase") at mem.c:1662
#2  0x00668a15 in gdbmsetfn (pm=0x8737a90, val=0x8731998 "testdata") at db_gdbm.c:348
#3  0x080b1c1c in assignstrvalue (v=0xbfbd4cdc, val=0x8731998 "testdata", flags=0) at params.c:2456
#4  0x080b3629 in assignsparam (s=0xb775abad "[testkey]", val=0x8731998 "testdata", flags=0) at params.c:3035
#5  0x08070c6c in addvars (state=0xbfbd50a0, pc=0xb775ab30, addflags=0) at exec.c:2462
#6  0x0806d5a4 in execsimple (state=0xbfbd50a0) at exec.c:1173
#7  0x0806daa6 in execlist (state=0xbfbd50a0, dont_change_job=0, exiting=0) at exec.c:1312
#8  0x0806d473 in execode (p=0xb775ab00, dont_change_job=0, exiting=0, context=0x80edc37 "toplevel") at exec.c:1130
#9  0x0808ccdd in loop (toplevel=1, justonce=0) at init.c:208
#10 0x080901d8 in zsh_main (argc=1, argv=0xbfbd5344) at init.c:1692
#11 0x0805433c in main (argc=1, argv=0xbfbd5344) at ./main.c:93



Messages sorted by: Reverse Date, Date, Thread, Author