Page 1 of 1
Raised exception class $C0000005 with message 'access violation'
Posted: 02.02.2023, 21:25
by gustavototta
Hello, how are you?
In my application there is a function to refresh the queries, but sometimes it is returning ACESS VIOLATION in the "OPEN" method. After clicking on "break" the pointer takes the code to the unit "ZDbcCache.pas", more precisely in the procedure TZRowAccessor.SetNull(ColumnIndex: Integer);
Could someone tell me how to solve this problem, please?
I currently use Delphi 10 Seattle with Zeos 8.0.0-beta
Previously with Delphi 7 and Zeos 7.2 the error was not displayed in the same application (I am in the process of migrating from D7 to Delphi Seattle)
Thank you all for your help!
Code: Select all
procedure RefreshQuery(vmo_ParQuery: TZQuery);
begin
with (vmo_ParQuery as TZQuery) do
begin
DisableControls;
Close;
Open;
EnableControls;
end;
end;
____________
---------------------------
Debugger Exception Notification
---------------------------
Project Prisma5_MD.exe raised exception class $C0000005 with message 'access violation at 0x0075117a: read of address 0xc2b64469'.
Re: Raised exception class $C0000005 with message 'access violation'
Posted: 03.02.2023, 10:38
by marsupilami
Hello,
which database do you use? Could you try to create a small sample application that reproduces the problem? This really can help in tracking the bug down.
Best regards,
Jan
Re: Raised exception class $C0000005 with message 'access violation'
Posted: 03.02.2023, 12:30
by gustavototta
Hello,
Database: PostgreSql 9.3
I don't know if I can replicate the error in an isolated application, because our application has many routines to reach the problem. (we also have many external units)
We can think of something you can help us with, maybe a connection with anydesk or something similar.
What you think about?
Thanks!
Re: Raised exception class $C0000005 with message 'access violation'
Posted: 06.02.2023, 11:38
by marsupilami
I had a small discussion with the developer who did that part of Zeos. He will take a look today. We hope to be able to give you a more detailed answer tomorrow.
Re: Raised exception class $C0000005 with message 'access violation'
Posted: 06.02.2023, 17:29
by gustavototta
Hello how are you?
I understand perfectly, I'm waiting. Thanks in advance for your attention!
Hugs
Re: Raised exception class $C0000005 with message 'access violation'
Posted: 09.02.2023, 15:05
by gustavototta
marsupilami wrote: ↑06.02.2023, 11:38
I had a small discussion with the developer who did that part of Zeos. He will take a look today. We hope to be able to give you a more detailed answer tomorrow.
How are you?
Did you get any response from the ZeosLib developer regarding the access violation we mentioned, please?
Thanks
Re: Raised exception class $C0000005 with message 'access violation'
Posted: 10.02.2023, 10:44
by marsupilami
Hello,
yes, I got a response. He tried to reproduce the problem bud couldn't do so. He asked the question wether you use persistent fields, meaning Fields that are created in the Delphi IDE and where you can set properties during design time?
Unfortunately we are tight on time currently - so finding a time where we can access your computer and resolve the problem there is very limited.
Regarding the creation of a minimum working example:
Is there a query where you always get that error? What happens if you copy that form into a new project and try to open that query? What happens if you try to read data in this modified query from an empty table?
Best regards,
Jan
Re: Raised exception class $C0000005 with message 'access violation'
Posted: 14.02.2023, 17:37
by gustavototta
Hello how are you?
We managed to identify a field that was like fkCalculated, that was the problem.
This probably happened when migrating from Delphi 7 to Delphi 10 Seattle, in the past there was no problem and after updating with the new Delphi + Zeos 8.0 it started giving access violation.
Thank you for your attention!
Re: Raised exception class $C0000005 with message 'access violation'
Posted: 28.09.2024, 09:57
by h_visli
Today I encountered the same problem. (Lazarus 3.4 + ZeosLib 8.0)
I am using TZQuery and TDBGrid to display a query result, and I implemented the sorting functionality by clicking the header of the TDBGrid control.
My query results include a series of fields from the database table as well as three calculated fields. When I click the header of these three calculated fields, a memory access error occurs (clicking non-calculated fields works fine).
The error comes from TZRowAccessor.SetNull() :
Code: Select all
procedure TZRowAccessor.SetNull(ColumnIndex: Integer);
var Data: PPointer;
begin
{$IFNDEF DISABLE_CHECKING}
CheckColumnIndex(ColumnIndex);
{$ENDIF}
{$R-}
if (FBuffer.Columns[FColumnOffsets[ColumnIndex{$IFNDEF GENERIC_INDEX} - 1{$ENDIF}]] = bIsNotNull) then begin
Data := @FBuffer.Columns[FColumnOffsets[ColumnIndex{$IFNDEF GENERIC_INDEX} - 1{$ENDIF}] + 1];
FBuffer.Columns[FColumnOffsets[ColumnIndex{$IFNDEF GENERIC_INDEX} - 1{$ENDIF}]] := bIsNull;
{$IFDEF RangeCheckEnabled}{$R+}{$ENDIF}
case FColumnTypes[ColumnIndex{$IFNDEF GENERIC_INDEX} - 1{$ENDIF}] of
stAsciiStream, stBinaryStream, stUnicodeStream:
PIZLob(Data)^ := nil;
stBytes, stString, stUnicodeString:
if Data^ <> nil then begin
System.FreeMem(Data^); <----- Error come from this line.
Data^ := nil;
end;
{$IFDEF WITH_CASE_WARNING}else ;{$ENDIF}
end;
end;
end;
Error comes from "
System.FreeMem(Data^);"
Here is the sorting code:
Code: Select all
procedure TForm1.DBGrid1TitleClick(Column: TColumn);
var
bm: TBookmark;
G: TDBGrid;
Q: TZQuery;
S: string;
imgIdx: integer;
begin
G := Column.Grid as TDBGrid;
Q := G.DataSource.DataSet as TZQuery;
if (Q = nil) or not Q.Active or Q.IsEmpty then exit;
if (Column.Field.DataType in [ftUnknown, ftBytes, ftVarBytes, ftBLOB,
ftMemo, ftGraphic, ftFmtMemo, ftWideMemo]) then
exit;
bm := Q.GetBookmark;
Q.DisableControls;
try
s := Q.IndexFieldNames;
if POS(Column.FieldName + ' Desc', s) = 0 then
begin
Q.IndexFieldNames := Column.FieldName + ' Desc';
imgIdx := 1;
end
else
begin
Q.IndexFieldNames := Column.FieldName;
imgIdx := 0;
end;
Column.Title.ImageIndex := imgIdx;
if (G.Tag > 0) and (G.Tag <> Column.Index + 1) then
G.Columns[G.Tag - 1].Title.ImageIndex := -1;
G.Tag := column.Index + 1;
finally
Q.GotoBookmark(bm);
Q.FreeBookmark(bm);
Q.EnableControls;
end;
end;
I spent an entire afternoon experimenting with why this error occurs, but unfortunately, I couldn't find the cause of the problem.
In the end, I tried to set up TZQuery in the following steps, and it seems that this avoids the memory access error:
1. Add the three calculated fields in TZQuery;
2. Add the SQL query statement in TZQuery.SQL;
3. Set TZQuery.Active=True;
4. Add all the fields from the query results to TZQuery;
5. Setup TDatasource and TDBGrid.
The key step here is Step 1, where all calculated fields must be added first.
Re: Raised exception class $C0000005 with message 'access violation'
Posted: 30.09.2024, 12:00
by marsupilami
Hello,
I seem to remember that this was fixed in the current 8.0-patches branch. Could you please thest, if it works for you if you download
the current version from SVN?
Best regards,
Jan
Re: Raised exception class $C0000005 with message 'access violation'
Posted: 01.10.2024, 04:46
by h_visli
OK, It work fine with 8.0-patches branch.
Thank you, @marsupilami.