Page 1 of 1
SIGSEGV in TZRowAccessor.GetInt after calling Query.Refresh
Posted: 14.08.2022, 07:16
by universe
Hello All,
I am facing a random access violation (program exits silently or after showing "Access violation") after running Query.Refresh
What is embarrassing most is that I failed to reproduce it with a minimal program.
It occurs in file 'source\dbc\ZDbcCache.pas' at line
Code: Select all
function TZRowAccessor.GetInt(ColumnIndex: Integer; out IsNull: Boolean): Integer;
var
Data: PPointer;
PW: PWideChar;
PA: PAnsiChar absolute PW;
Len: NativeUint;
begin
{$IFNDEF DISABLE_CHECKING}
CheckColumnConvertion(ColumnIndex, stInteger);
{$ENDIF}
Result := 0;
{$R-}
-----> if FBuffer.Columns[FColumnOffsets[ColumnIndex{$IFNDEF GENERIC_INDEX} - 1{$ENDIF}]] = bIsNotNull then begin
The query is similar to:
Code: Select all
SELECT id,name FROM foo WHERE name IN (SELECT label FROM bar);
Then I call Query.Refresh programmatically, which gives either segmentation fault, or silent program exit, or just does the refresh.
Any help could be appreciated.
Thank you.
Re: SIGSEGV in TZRowAccessor.GetInt after calling Query.Refresh
Posted: 15.08.2022, 08:46
by marsupilami
Hello universe
this somehow seems strangely familiar to me. Are you sure, you are using the latest revision of Zeos 8.0 (not trunk/master) from SVN or GIT?
Best regards,
Jan
Re: SIGSEGV in TZRowAccessor.GetInt after calling Query.Refresh
Posted: 16.08.2022, 12:00
by universe
Hello,
The version is packed with Codetyphon 7.7 and is marked 8.0.0 alpha.
I will check repository, ask in CT forum, then report back.
Thank you.
Re: SIGSEGV in TZRowAccessor.GetInt after calling Query.Refresh
Posted: 16.08.2022, 14:40
by marsupilami
universe wrote: ↑16.08.2022, 12:00
The version is packed with Codetyphon 7.7 and is marked 8.0.0 alpha.
Hmmm - I am not sure, if we ever changed to beta. But we definitly have no control over the things Code Typhoon does. We don't support it. Our suggestion is to use plain Lazarus and FPC in their stable versions.
universe wrote: ↑16.08.2022, 12:00
I will check repository, ask in CT forum, then report back.
I suggest you uninstall Zeos from CT, get the current 8.0 version from SVN or GIT and install it.
Re: SIGSEGV in TZRowAccessor.GetInt after calling Query.Refresh
Posted: 16.08.2022, 21:31
by universe
Hello,
The bad new I have the replaced all source files by those in
https://github.com/frones/ZeosLib/tree/8.0-patches but the problem remains.
The good news I have reproduced the issue
.
1. Open a ZQuery with
Code: Select all
select * from foo where name = 'test'
which must returns data.
2. Delete all data for this condition, or just truncate the table.
3. Call refresh
4. SIGSEGV raised @ GetBlob, GetPAnsiChar etc. Depending on field types returned by SELECT statement.
PS: When I call
all goes fine.
If you could give me some hints to investigate more?
Thank you.
Re: SIGSEGV in TZRowAccessor.GetInt after calling Query.Refresh
Posted: 17.08.2022, 18:03
by universe
Hello, It seems I made someone upset here
,
Well this time I get the files from
https://sourceforge.net/p/zeoslib/code- ... 0-patches/ marked r7860, no mistake.
But I still have the error.
Meanwhile I am still struggling and trying to resolve the issue.
Thanks for your time.
Re: SIGSEGV in TZRowAccessor.GetInt after calling Query.Refresh
Posted: 18.08.2022, 07:57
by universe
Hello,
I did a small "optimization"
Code: Select all
ColumnOffset := FColumnOffsets[ColumnIndex{$IFNDEF GENERIC_INDEX} - 1{$ENDIF}]
to locate witch array is generating the access violation, as follows,
Code: Select all
function TZRowAccessor.GetInt(ColumnIndex: Integer; out IsNull: Boolean): Integer;
var
Data: PPointer;
PW: PWideChar;
PA: PAnsiChar absolute PW;
Len: NativeUint;
ColumnOffset: integer;
begin
{$IFNDEF DISABLE_CHECKING}
CheckColumnConvertion(ColumnIndex, stInteger);
{$ENDIF}
Result := 0;
{$R-}
ColumnOffset := FColumnOffsets[ColumnIndex{$IFNDEF GENERIC_INDEX} - 1{$ENDIF}];
if FBuffer.Columns[ColumnOffset] = bIsNotNull then begin
Data := @FBuffer.Columns[ColumnOffset + 1];
And I got "Cannot read address 0x09" hint for FBuffer.Columns, while ColumnOffset is equla to zero.
Re: SIGSEGV in TZRowAccessor.GetInt after calling Query.Refresh
Posted: 18.08.2022, 08:34
by Fr0sT
From what you discovered, I suspect the buffer is being accessed when it's actually empty because of empty dataset
Re: SIGSEGV in TZRowAccessor.GetInt after calling Query.Refresh
Posted: 18.08.2022, 21:40
by universe
Hello,
Thanks for your reply.
I have started a new whole project which contains two ZQueries linked to the same table, in one I insert and delete and the other I refresh in-between, and it works.
The problem is related to my project, what is strange the "Access violation" is raised only when the dataset is empty. And there is no special thing in there, only that it's a bigger application.
Re: SIGSEGV in TZRowAccessor.GetInt after calling Query.Refresh
Posted: 18.08.2022, 22:17
by universe
universe wrote: ↑18.08.2022, 21:40
And there is no special thing in there, only that it's a bigger application.
No, there is a difference, (which was working previously with ZeosLib 7.2), that I am sending the query as parameter, after removing it the problem was solved.
Is the issue related to the assign method in ZeosLib 8.0?
Re: SIGSEGV in TZRowAccessor.GetInt after calling Query.Refresh
Posted: 20.08.2022, 09:32
by marsupilami
universe wrote: ↑17.08.2022, 18:03
Hello, It seems I made someone upset here
,
Why?
Fr0sT wrote: ↑18.08.2022, 08:34
From what you discovered, I suspect the buffer is being accessed when it's actually empty because of empty dataset
True. Zeos 7.2 had a row buffer in this case whereas Zeos 8 didn't. This lead to an access violation.
The problem should be fixed in the latest revision of Zeos 8 and Zeos trunk / master.
Re: SIGSEGV in TZRowAccessor.GetInt after calling Query.Refresh
Posted: 20.08.2022, 11:05
by universe
Hello,
No, just because you didn't reply in time
Fr0sT wrote: ↑18.08.2022, 08:34
From what you discovered, I suspect the buffer is being accessed when it's actually empty because of empty dataset
Yes, and even after changing the function I used in my main program (sending statement instead of query), it worked for sometime now the Access violation is back.
What is strange is that Length(FBuffer) is always reporting 32769 even when it's nil.
marsupilami wrote: ↑20.08.2022, 09:32
True. Zeos 7.2 had a row buffer in this case whereas Zeos 8 didn't. This lead to an access violation.
The problem should be fixed in the latest revision of Zeos 8 and Zeos trunk / master.
I hope so, I added nil check for all
Code: Select all
if FBuffer.Columns[FColumnOffsets[ColumnIndex{$IFNDEF GENERIC_INDEX} - 1{$ENDIF}]] = bIsNotNull then begin
with
Code: Select all
if (FBuffer<>nil) and (FBuffer.Columns[FColumnOffsets[ColumnIndex{$IFNDEF GENERIC_INDEX} - 1{$ENDIF}]] = bIsNotNull) then begin
Except for GetBlob
Code: Select all
IsNull := (FBuffer=nil) or (FBuffer.Columns[FColumnOffsets[ColumnIndex]] = bIsNull);
Now for time being it's working.
Still, I am testing the program.
Thank you all.
Re: SIGSEGV in TZRowAccessor.GetInt after calling Query.Refresh
Posted: 21.08.2022, 09:42
by universe
Hello,
The "nill" check fixed the issue.
Thanks.
Re: SIGSEGV in TZRowAccessor.GetInt after calling Query.Refresh
Posted: 02.02.2023, 20:32
by gustavototta
Hi, how i can fix this issue?
I replace the lines according to your statement in my "ZDbcCache.pas", but access violation still occurs.
Could you help me, please?
Thank you!
Re: SIGSEGV in TZRowAccessor.GetInt after calling Query.Refresh
Posted: 02.02.2023, 20:36
by gustavototta
Hello, can you help me fix this issue?
I replace the lines according to your statement in my file "ZDbcCache.pas", but access violation still occurs. Could you help me, please?
Thank you!