“指定给 RtlFreeHeap( 06450000, 08387460 ) 的地址无效” 是什么意思?意思是?

发布于 2024-10-31 03:15:04 字数 3502 浏览 2 评论 0原文

有时我的 Delphi 程序会随机崩溃。我的程序停止,调试器输出:

指定给 RtlFreeHeap( 06450000, 08387460 ) 的地址无效

这是什么意思?什么可能导致它?

这是CPU Inspector停止的地方:

77BA0845 C6052582BD7700 mov byte ptr [$77bd8225],$00

请注意,它们是非常随机的(对我来说)。有时它们根本不出现。

我正在使用 Skype 的 Skype4COM.dll - 但没有来源。

如果您需要它,这里是代码。我已经评论了大多数 Synchronize 调用,因此您知道它们的作用。

////////////////////////////////////////////////////////////////////////////////
/// Execute
////////////////////////////////////////////////////////////////////////////////
procedure TContactDeletor.Execute;
Var
  I             : Integer;
  UserObj       : PUser;
  User          : IUser;
  PauseEvent    : TEvent;
begin
  inherited;
  FreeOnTerminate       := True;
  if Terminated then
  Exit;

  CoInitialize(Nil);
  // The F-Flags are to make sure TSkype events do not fire (from my Main Thread)
  FAllowUI              := False;
  FUserIsBeingDeleted   := False;
  FUseGroupUsersEvent   := False;
  FUseRenameEvent       := False;
  SkypeThr              := TSkype.Create(Nil);
  SkypeThr.Attach(10,False);
  SkypeThr.Cache        := False;
  MyList                := TStringList.Create;
  PauseEvent            := TEvent.Create(True);
  try
  // This fills my Stringlist
  Synchronize(GrabList);
  if Terminated then Exit;


  iMax                  := MyList.Count;
  // This sets the Max of my Progressbar
  Synchronize(SetMax);
  Try
  for I := 0 to MyList.Count - 1 do
    begin

      {while SkypeThr.AttachmentStatus <> apiAttachSuccess do
      begin
        SkypeThr.Attach(10,False);
        Synchronize(Procedure Begin Log('Skype Unavailable - Trying to reconnect ...'); End);
        PauseEvent.WaitFor(5000);
      end;  }

      CurUser := '';
      User := SkypeThr.User[MyList[I]];
      CurUser := MyList[I];

      Try
      User.IsAuthorized := False;
      User.BuddyStatus := budDeletedFriend;
      Except on E:Exception do
      begin
       ExErr := E.Message;
       ExLog := 'Error while deleting contacts: ';
       ExMsg := 'An Error has occured while deleting contacts: ';
       Synchronize(
       Procedure
       Begin
        Log(ExLog+ExErr+sLineBreak+' - Last logged Handle: '+CurUser);
       End
       );    
      end;
      end;

      iProgress := I+1;
      // This updates my log and my progressbar.
      Synchronize(UpdatePG);
      PauseEvent.WaitFor(100);

      if (I mod 200 = 0) and (I > 0) then
        begin
          // Calls to Synchronize updates my log
          Synchronize(SyncPauseBegin);
          PauseEvent.WaitFor(3000);
          Synchronize(SyncPauseEnd);
        end;


    end;
  // Except
  Except on E:Exception do
  begin
   ExErr := E.Message;
   ExLog := 'Error while deleting contacts: ';
   ExMsg := 'An Error has occured while deleting contacts: ';
   Synchronize(
   Procedure
   Begin
    Log(ExMsg+ExErr+sLineBreak+' - Last logged Handle: '+CurUser);
    ErrMsg(ExMsg+ExErr+sLineBreak+sLineBreak+' - Last logged Handle: '+CurUser);
   End
   );
   Exit;
  end;
  end;
  // This synchronizes my visual list.
  Synchronize(SyncList);
  finally
   FUserIsBeingDeleted   := False;
   FUseGroupUsersEvent   := True;
   FUseRenameEvent       := True;
   FAllowUI              := True;
   Synchronize(
   Procedure
   Begin
   frmMain.UpdateStatusBar;
   PleaseWait(False);
   ToggleUI(True);
   end);
   PauseEvent.Free;
   SkypeThr.Free;
   MyList.Free;
   CoUninitialize;
  end;


end;

Sometimes I experience random crashes in my Delphi program. My program halts, and the Debugger outputs:

Invalid address specified to RtlFreeHeap( 06450000, 08387460 )

What does that mean? And what can possibly cause it?

This is where the CPU Inspector stopped:

77BA0845 C6052582BD7700 mov byte ptr [$77bd8225],$00

Please note that they are very random (for me). Sometimes they don't appear at all.

I am using the Skype4COM.dll from Skype - there's no source though.

In case you need it, here is the code. I have commented most of the calls to Synchronize, so you know what they do.

////////////////////////////////////////////////////////////////////////////////
/// Execute
////////////////////////////////////////////////////////////////////////////////
procedure TContactDeletor.Execute;
Var
  I             : Integer;
  UserObj       : PUser;
  User          : IUser;
  PauseEvent    : TEvent;
begin
  inherited;
  FreeOnTerminate       := True;
  if Terminated then
  Exit;

  CoInitialize(Nil);
  // The F-Flags are to make sure TSkype events do not fire (from my Main Thread)
  FAllowUI              := False;
  FUserIsBeingDeleted   := False;
  FUseGroupUsersEvent   := False;
  FUseRenameEvent       := False;
  SkypeThr              := TSkype.Create(Nil);
  SkypeThr.Attach(10,False);
  SkypeThr.Cache        := False;
  MyList                := TStringList.Create;
  PauseEvent            := TEvent.Create(True);
  try
  // This fills my Stringlist
  Synchronize(GrabList);
  if Terminated then Exit;


  iMax                  := MyList.Count;
  // This sets the Max of my Progressbar
  Synchronize(SetMax);
  Try
  for I := 0 to MyList.Count - 1 do
    begin

      {while SkypeThr.AttachmentStatus <> apiAttachSuccess do
      begin
        SkypeThr.Attach(10,False);
        Synchronize(Procedure Begin Log('Skype Unavailable - Trying to reconnect ...'); End);
        PauseEvent.WaitFor(5000);
      end;  }

      CurUser := '';
      User := SkypeThr.User[MyList[I]];
      CurUser := MyList[I];

      Try
      User.IsAuthorized := False;
      User.BuddyStatus := budDeletedFriend;
      Except on E:Exception do
      begin
       ExErr := E.Message;
       ExLog := 'Error while deleting contacts: ';
       ExMsg := 'An Error has occured while deleting contacts: ';
       Synchronize(
       Procedure
       Begin
        Log(ExLog+ExErr+sLineBreak+' - Last logged Handle: '+CurUser);
       End
       );    
      end;
      end;

      iProgress := I+1;
      // This updates my log and my progressbar.
      Synchronize(UpdatePG);
      PauseEvent.WaitFor(100);

      if (I mod 200 = 0) and (I > 0) then
        begin
          // Calls to Synchronize updates my log
          Synchronize(SyncPauseBegin);
          PauseEvent.WaitFor(3000);
          Synchronize(SyncPauseEnd);
        end;


    end;
  // Except
  Except on E:Exception do
  begin
   ExErr := E.Message;
   ExLog := 'Error while deleting contacts: ';
   ExMsg := 'An Error has occured while deleting contacts: ';
   Synchronize(
   Procedure
   Begin
    Log(ExMsg+ExErr+sLineBreak+' - Last logged Handle: '+CurUser);
    ErrMsg(ExMsg+ExErr+sLineBreak+sLineBreak+' - Last logged Handle: '+CurUser);
   End
   );
   Exit;
  end;
  end;
  // This synchronizes my visual list.
  Synchronize(SyncList);
  finally
   FUserIsBeingDeleted   := False;
   FUseGroupUsersEvent   := True;
   FUseRenameEvent       := True;
   FAllowUI              := True;
   Synchronize(
   Procedure
   Begin
   frmMain.UpdateStatusBar;
   PleaseWait(False);
   ToggleUI(True);
   end);
   PauseEvent.Free;
   SkypeThr.Free;
   MyList.Free;
   CoUninitialize;
  end;


end;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

水溶 2024-11-07 03:15:04

Najem 是对的,这是因为你的堆已损坏。为了更容易调试,您应该启用 PageHeap,同时使用调试 CRT(或调试 delphi 运行时) )尽可能多,直到你找出是什么破坏了你的记忆。

很多时候,损坏可能只会溢出几个字节。然后您的应用程序可以在很长一段时间内正常运行,因此您直到很久以后才会注意到任何错误(如果有的话)。

当您寻找内存损坏错误时,请尝试干净地退出应用程序,不要只是停止调试器,当您的进程退出时,它应该“触及”之前分配的大部分内存,这将使您有机会检测到故障。

Najem was correct, it is because your heap is corrupted. To debug it easier, you should enable PageHeap, also, use the debug CRT (or debug delphi runtime) as much as possiable until you find out what's corrupting your memory.

A lot of the time, the corruption may only spill over a few bytes. Then your application can run fine for a very long time, so you will not notice anything wrong until much later, if at all.

Try to exit your application cleanly when your looking for memory corruption bugs, dont just stop the debugger, when your process is exiting, it should "touch" most of the memory it allocated earlier and it will give you a chance to detect the failure.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文