2

我已经为 XE5 Update1 更新了我的几个应用程序。此后,ShowMessage 频繁触发访问冲突。这发生在几个应用程序中,没有明显的原因。如果我用简单的形式替换 ShowMessage,那么 AV 就消失了。所以这显然是罪魁祸首 ShowMessage。

AV 出现在函数 TaskDialogIndirect 中的 WinApi.CommCtrl.pas 中(参见下面的标记行):

function TaskDialogIndirect(const pTaskConfig: TTaskDialogConfig;
  pnButton: PInteger; pnRadioButton: PInteger; pfVerificationFlagChecked: PBOOL): HRESULT;
begin
  if Assigned(_TaskDialogIndirect) then
    Result := _TaskDialogIndirect(pTaskConfig, pnButton, pnRadioButton,
      pfVerificationFlagChecked)         // <====== HERE ==========
  else
  begin
    InitComCtl;
    Result := E_NOTIMPL;
    if ComCtl32DLL <> 0 then
    begin
      @_TaskDialogIndirect := GetProcAddress(ComCtl32DLL, 'TaskDialogIndirect');
      if Assigned(_TaskDialogIndirect) then
        Result := _TaskDialogIndirect(pTaskConfig, pnButton, pnRadioButton,
          pfVerificationFlagChecked)
    end;
  end;
end;

异常发生时的堆栈跟踪:

:671cab85 ; D:\Development\DelphiLibs\madCollection\madExcept\Dlls\madExcept32.dll
:671cabe2 ; D:\Development\DelphiLibs\madCollection\madExcept\Dlls\madExcept32.dll
:671ca755 madExcept32.ThisIsNoLeak + 0x29
:004aa9d7 ThisIsNoLeak + $F
:004a9412 HookedCreateThread + $82
:769613a2 msvcrt._beginthreadex + 0x74
:5f028473 ; C:\Windows\SysWOW64\DUser.dll
:5f028234 DUser.InitGadgets + 0xf5
:5f028177 DUser.InitGadgets + 0x38
:70e4da8d ; C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_41e6975e2bd6f2b2\comctl32.dll
:70e5d492 ; C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_41e6975e2bd6f2b2\comctl32.dll
Winapi.CommCtrl.TaskDialogIndirect(???,???,$18E974,$18E96C)
Vcl.Dialogs.TCustomTaskDialog.DoExecute(460578)
Vcl.Dialogs.TCustomTaskDialog.Execute(???)
Vcl.Dialogs.TTaskMessageDialog.Execute(???)
Vcl.Dialogs.TCustomTaskDialog.Execute
Vcl.Dialogs.DoTaskMessageDlgPosHelp('','Calibration failed Unknown error',mtCustom,[mbOK],0,-1,-1,'',mbOK)
Vcl.Dialogs.DoTaskMessageDlgPosHelp('',???,mtCustom,[mbOK],0,-1,-1,'')
Vcl.Dialogs.MessageDlgPosHelp('Calibration failed Unknown error',mtCustom,[mbOK],0,-1,-1,'')
Vcl.Dialogs.ShowMessagePos('',-1,-1)
Vcl.Dialogs.ShowMessage(???)
AutomationTechspCalibration.TCalibrationForm.StartCalibrationButtonClick($8C56D14)
Vcl.Controls.TControl.Click
Vcl.StdCtrls.TCustomButton.Click
Vcl.StdCtrls.TCustomButton.CNCommand(???)
Vcl.Controls.TControl.WndProc((48401, 1786, 526074, 0, 1786, 0, (), 1786, 8, (), 0, 0, ()))
Vcl.Controls.TWinControl.WndProc((48401, 1786, 526074, 0, 1786, 0, (), 1786, 8, (), 0, 0, ()))
Vcl.StdCtrls.TButtonControl.WndProc((48401, 1786, 526074, 0, 1786, 0, (), 1786, 8, (), 0, 0, ()))
Vcl.Controls.TControl.Perform(???,???,526074)
Vcl.Controls.DoControlMsg(???,(no value))
Vcl.Controls.TWinControl.WMCommand((273, (), 1786, 0, (), 526074, 0))
Vcl.Forms.TCustomForm.WMCommand((273, (), 1786, 0, (), 526074, 0))
Vcl.Controls.TControl.WndProc((273, 1786, 526074, 0, 1786, 0, (), 1786, 8, (), 0, 0, ()))
Vcl.Controls.TWinControl.WndProc((273, 1786, 526074, 0, 1786, 0, (), 1786, 8, (), 0, 0, ()))
Vcl.Forms.TCustomForm.WndProc((273, 1786, 526074, 0, 1786, 0, (), 1786, 8, (), 0, 0, ()))
Vcl.Controls.TWinControl.MainWndProc(???)
System.Classes.StdWndProc(460578,273,1786,526074)
:757462fa ; C:\Windows\syswow64\USER32.dll
:75746d3a USER32.GetThreadDesktop + 0xd7
:7574965e ; C:\Windows\syswow64\USER32.dll
:757496c5 USER32.SendMessageW + 0x4c
:70e84601 ; C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_41e6975e2bd6f2b2\comctl32.dll
:70e84663 ; C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_41e6975e2bd6f2b2\comctl32.dll
:70e844ed ; C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_41e6975e2bd6f2b2\comctl32.dll
:757462fa ; C:\Windows\syswow64\USER32.dll
:75746d3a USER32.GetThreadDesktop + 0xd7
:75750d27 USER32.GetClientRect + 0xc5
:75750d4d USER32.CallWindowProcW + 0x1b
Vcl.Controls.TWinControl.DefaultHandler(???)
:005b92ef TWinControl.DefaultHandler + $EB
:005b91de TWinControl.WndProc + $5CA
:005d6599 TButtonControl.WndProc + $71
:0053ea12 StdWndProc + $16
:757462fa ; C:\Windows\syswow64\USER32.dll
:75746d3a USER32.GetThreadDesktop + 0xd7
:757477c4 ; C:\Windows\syswow64\USER32.dll
:7574788a USER32.DispatchMessageW + 0xf

任何帮助表示赞赏。

4

1 回答 1

5

我禁用了 madExcept 并使用了 FastMM4(不是 XE5 中包含的,而是 Sourceforge 的最新版本)。FastMM 立即向我显示了 madExcept 没有捕获的缓冲区溢出。

我解决了这个问题。我用 FastMM 工作了几个小时,然后我再次使用了 madExcept,一切正常。没有更多的AV。

我的结论是缓冲区溢出以一种导致 ShowMessage AV 的方式破坏了堆!madExcept 不是问题,ShowMessage 也不是。那是我自己的代码(缓冲区溢出),它搞砸了一切。感谢 FastMM 几乎立即指向它(打开 FastMM 的 FullDebugMode)。

于 2013-11-10T08:11:02.713 回答