UIB EventCallback中的访问冲突

时间:2014-03-13 19:15:40

标签: delphi firebird access-violation firebird2.5 uib

使用EurekaLog,我在我的应用程序中发现了此访问冲突:

 2.2 Address       : 00404A77
 2.5 Type          : EAccessViolation
 2.6 Message       : Access violation at address 00404A77 in module 'MyApp.exe'. Write of address 4F4F4E30.

调用堆栈:

--------------------------------------------------------------------------------------------
|Address |Module        |Unit           |Class          |Procedure/Method         |Line    |
--------------------------------------------------------------------------------------------
|*Exception Thread: ID=3748; Priority=??; Class=                                           |
|------------------------------------------------------------------------------------------|
|00404A77|MyApp.exe     |               |               |                         |        |
|75E1CD33|kernel32.dll  |               |               |LocalAlloc               |        |
|70BB2C72|MSVCR80.dll   |               |               |__set_flsgetvalue        |        |
|76F16FF2|ntdll.dll     |               |               |KiUserExceptionDispatcher|        |
|0064FC04|MyApp.exe     |uib.pas        |               |EventCallback            |4430[5] |
|70BB29A0|MSVCR80.dll   |               |               |_endthreadex             |        |
|75E1ED6A|kernel32.dll  |               |               |GetDriveTypeW            |        |
|------------------------------------------------------------------------------------------|

来自uib.pas的代码:

procedure EventCallback(UserData: Pointer; Length: Smallint; Updated: PAnsiChar); cdecl;
begin
  if (Length > 0) and (Updated <> nil) then
  if (Assigned(UserData) and Assigned(Updated)) then
  with TUIBEventThread(UserData) do
  begin
    Move(Updated^, FResultBuffer^, Length);
    FQueueEvent := True;
    FSignal.SetEvent;
  end;
end;

知道可能出现什么问题以及如何解决问题?

1 个答案:

答案 0 :(得分:1)

根据评论,提出访问冲突的行是对Move的调用。因此,诊断程序告诉您指向目标缓冲区的指针未指向长度至少为Length的有效缓冲区。

换句话说,你的问题是:

  • FResultBuffer是无效指针,或
  • FResultBuffer所指的缓冲区不够长。