Subject | Interbase blows up big time (UDF) |
---|---|
Author | Anthony Ison |
Post date | 2003-03-26T06:22Z |
Hi all,
Not sure if this is the right place for this.
I am using FreeUDFLib.dll with my own addition... I expect this is my
problem...
Infrequently, Interbase blows up with an Access Violation in the logs. I
have put together some code after many hours of hunting for this obsure
problem... This code usually kills Interbase within 30 seconds. To
reproduce the problem, open two connections to the database and execute the
Boomer procedure on both.
I would appreciate any tips.
Thanks.
Anthony
My procedure: (running in an infinite loop)
CREATE PROCEDURE BOOMER AS
declare variable boom varchar(20);
declare variable i integer;
BEGIN
i = 0;
while (i = 0) do
begin
boom = '000000001234567890';
boom = F_LTrimZeros(boom);
end
END
The function definition:
DECLARE EXTERNAL FUNCTION F_LTRIMZEROS
CSTRING(254)
RETURNS CSTRING(254)
ENTRY_POINT "lTrimZeros" MODULE_NAME "FreeUDFLib.dll"
The function within FreeUDFLib.dll:
function lTrimZeros(sz: PChar): PChar;
var
i : integer;
str : string;
begin
str := TrimLeft(String(sz));
i := 1;
while (i < length(str)) and (Copy(str, i, 1) = '0') do
inc(i);
gResult.AsString := Copy(str, i, length(str));
result := gResult.AsPChar;
end;
The original function (with the same problem):
function lTrimZeros(sz: PChar): PChar;
begin
gResult.AsString := TrimLeft(String(sz));
while copy(gResult.Asstring, 1, 1) = '0' do
gResult.Asstring := copy(gResult.Asstring, 2, length(gResult.Asstring) -
1);
result := gResult.AsPChar;
end;
Not sure if this is the right place for this.
I am using FreeUDFLib.dll with my own addition... I expect this is my
problem...
Infrequently, Interbase blows up with an Access Violation in the logs. I
have put together some code after many hours of hunting for this obsure
problem... This code usually kills Interbase within 30 seconds. To
reproduce the problem, open two connections to the database and execute the
Boomer procedure on both.
I would appreciate any tips.
Thanks.
Anthony
My procedure: (running in an infinite loop)
CREATE PROCEDURE BOOMER AS
declare variable boom varchar(20);
declare variable i integer;
BEGIN
i = 0;
while (i = 0) do
begin
boom = '000000001234567890';
boom = F_LTrimZeros(boom);
end
END
The function definition:
DECLARE EXTERNAL FUNCTION F_LTRIMZEROS
CSTRING(254)
RETURNS CSTRING(254)
ENTRY_POINT "lTrimZeros" MODULE_NAME "FreeUDFLib.dll"
The function within FreeUDFLib.dll:
function lTrimZeros(sz: PChar): PChar;
var
i : integer;
str : string;
begin
str := TrimLeft(String(sz));
i := 1;
while (i < length(str)) and (Copy(str, i, 1) = '0') do
inc(i);
gResult.AsString := Copy(str, i, length(str));
result := gResult.AsPChar;
end;
The original function (with the same problem):
function lTrimZeros(sz: PChar): PChar;
begin
gResult.AsString := TrimLeft(String(sz));
while copy(gResult.Asstring, 1, 1) = '0' do
gResult.Asstring := copy(gResult.Asstring, 2, length(gResult.Asstring) -
1);
result := gResult.AsPChar;
end;