[fpc-pascal]Error running gdbmtest2.pp
Christian Müllerke
cm at cmuellerke.de
Thu Jul 29 22:18:47 CEST 2004
Hi!
Maybe I'd found a bug in gdbm.pp I'm running Linux (2.6.7) and fpc-1.9.4:
smile at mobil fpctest2 $ ./testgdbm2
Inserted string 1
Inserted string 2
Inserted string 3
Inserted string 4
Inserted string 5
Inserted string 6
Inserted string 7
Inserted string 8
Inserted string 9
Inserted string 10
Data for key 1 (string 7) : data for string 7
Data for key 2 (string 6) : data for string 6
Data for key 3 (string 5) : data for string 5
Data for key 4 (string 4) : data for string 4
Data for key 5 (string 10) : data for string 10
Data for key 6 (string 3) : data for string 3
Data for key 7 (string 2) : data for string 2
Data for key 8 (string 1) : data for string 1
Data for key 9 (string 9) : data for string 9
Data for key 10 (string 8) : data for string 8
An unhandled exception occurred at 0x0805B37C :
EAccessViolation : Access violation
$0805B37C
This seems to be a error in gdbm.pp:
Function DatumToString(Key : TDatum) : String;
begin
SetLength(DatumToString,Key.dsize);
If key.Dsize>0 then
Move(key.dptr^,DatumToString[1],key.dsize);
if key.dptr<>Nil then
cfree(Key.dptr);
end;
The function is called by function gdbm_nextkey(para1:PGDBM_FILE; Const
Para2 :string):string;
I'd changed the DatumToString() function to
Function DatumToString(Key : TDatum) : String;
begin
if key.dptr <> Nil then
begin
SetLength(DatumToString,Key.dsize);
If key.Dsize>0 then
Move(key.dptr^,DatumToString[1],key.dsize);
{ if key.dptr<>Nil then }
cfree(Key.dptr);
end;
end;
This now works (but due to a lack of experience with this unit it may be
wrong)
Anyone here who has the same error with testgdbm2.pp?
I will test next time I have my PC back the same on FreeBSD 5.x.
tia, Christian
More information about the fpc-pascal
mailing list