[bug_fixed] EOutofMemory with Delphi 2006 + Firebird

In this forum all bug reports concerning the 6.x branch will be gahtered. You have the possibility to track the bug fix process.

Moderators: EgonHugeist, mdaems

Post Reply
cariad
Junior Boarder
Junior Boarder
Posts: 36
Joined: 20.10.2005, 14:07

[bug_fixed] EOutofMemory with Delphi 2006 + Firebird

Post by cariad »

Hello,

I stumbled upon this, which looks like a bug.

Basically I get an EOutOfMemory error when I try to access a Fields[x].AsString from a TZQuery when the field is a ftWideString.

Bug occurs in ZAbstractRODataSet.pas at line 1195 (for trunk 187) :

Code: Select all

PWideString(Buffer)^ := RowAccessor.GetUnicodeString(ColumnIndex, Result)
It works with Delphi 7, but crash in Delphi 2006. I'm sorry I don't have any other version to test this further.

I've put together a sample Delphi project which trigger this bug (the convoluted query is used to get the table structure of the Firebird DB). You might need to copy the fbclient.dll to the app directory.

Please let me know if I overlooked something.
Thanks for your time,

Boris.
You do not have the required permissions to view the files attached to this post.
cariad
Junior Boarder
Junior Boarder
Posts: 36
Joined: 20.10.2005, 14:07

Post by cariad »

I found a fix by explicitly copying the string.

Replacing :

Code: Select all

PWideString(Buffer)^ := RowAccessor.GetUnicodeString(ColumnIndex, Result);
by :

Code: Select all

WStrCopy(Buffer, PWideChar(RowAccessor.GetUnicodeString(ColumnIndex, Result)));
Warning : WStrCopy() is defined in WideStrUtils.pas present with Delphi 2006, but not Delphi 7.

Here's the function code :

Code: Select all

function WStrCopy(Dest: PWideChar; const Source: PWideChar): PWideChar;
var
  Src : PWideChar;
begin
  Result := Dest;
  Src := Source;
  while (Src^ <> #$00) do
  begin
    Dest^ := Src^;
    Inc(Src);
    Inc(Dest);
  end;
  Dest^ := #$00;
end;
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Thanks for the fix.
Incompatibility with versions below D2006 makes we have to IFDEF this construct.

Mark
magnomp
Fresh Boarder
Fresh Boarder
Posts: 10
Joined: 08.01.2007, 17:39

Post by magnomp »

I have this problem too, using a BDS2006 with all updates and hotfixes, but worked fine with a BDS2006 without updates and hotfixes.

Running the following query over FB 1.5.3:
SELECT
RDB$TYPE_NAME A,
RDB$TYPE_NAME B
FROM
RDB$TYPES
the error triggers when I try to read the field B.
Debugging Zeos, I see that both fields are initially ftString, but in a certain momment, the second field changes to ftWideString (field A remains as ftString). If I use the Evaluate/Modify window to force the field B back to ftString type, I don't get any error.
So, I thing that the problem cause is that a field that should be ftString is modified to ftWideString

I hope this information may be usefull for resolving the error, and sorry by my bad english.

P.S.: There is a idea about when the correction for this bug will be avaliable in a release?
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Hi,

Fduenas has just sent me a working patch that is backwards compatible (at least for D7, which I tested using the test suite). I commited it to SVN testing branch (rev 208).

Can you confirm it's OK for you with this patch?

Mark
You do not have the required permissions to view the files attached to this post.
cariad
Junior Boarder
Junior Boarder
Posts: 36
Joined: 20.10.2005, 14:07

Post by cariad »

I've just tested it with BDS2006+Updates, and it works Ok. Thanks for the commit.
Post Reply