本文介绍了应用启动时Delphi XE5违反法规的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在两台计算机上都可以,在三台计算机上,具有相同的例外,并且具有相同的AV地址。谢谢帮助

On two computers is ok, on three there is the same exception with the same addres for AV. Thank for help

begin
  Application.Hinthidepause := 30000;
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm2, Form2);
  Application.CreateForm(TForm3, Form3);
  Application.CreateForm(TForm4, Form4);
  Application.Run;
end;
exception class    : EAccessViolation
exception message  : Access violation at address 00405361 in module 'Project1.exe'. Read of address 00000064.

main thread ($1d44):
00405361 +3d Project1.exe System         75  +0 SysGetMem
00406827 +3f Project1.exe System         75  +0 @ReallocMem
0040c38c +d8 Project1.exe System         75  +0 DynArraySetLength
0040c4bd +05 Project1.exe System         75  +0 @DynArraySetLength
005465af +23 Project1.exe System.Classes        {System.Generics.Collections}TList<System.Generics.Collections.TList<System.Classes.TComponent>>.SetCapacity
005466b0 +2c Project1.exe System.Classes        {System.Generics.Collections}TList<System.Generics.Collections.TList<System.Classes.TComponent>>.Grow
005466d2 +16 Project1.exe System.Classes        {System.Generics.Collections}TList<System.Generics.Collections.TList<System.Classes.TComponent>>.GrowCheck
00546a4d +0d Project1.exe System.Classes        {System.Generics.Collections}TList<System.Generics.Collections.TList<System.Classes.TComponent>>.Add
0051e75e +36 Project1.exe System.Classes        BeginGlobalLoading
0051e8de +46 Project1.exe System.Classes        InitInheritedComponent
0064cfde +c6 Project1.exe Vcl.Forms             TCustomForm.Create
00657ffa +76 Project1.exe Vcl.Forms             TApplication.CreateForm
00883ce7 +c7 Project1.exe Project1  54 +13 initialization
76a13368 +10 kernel32.dll

更新
此过程存在问题:

UPDATEProblem was with this procedure:

procedure KopiujRTF(const Source, destination: TRichEdit);
var
  rtfStream: TEditStream;
  sourceStream: TMemoryStream;
  function EditStreamReader(dwCookie: DWORD; pBuff: Pointer; cb: LongInt;
    pcb: PLongInt): DWORD; stdcall;
  begin
    Result := $0000;
    try
      pcb^ := TStream(dwCookie).Read(pBuff^, cb);
    except
      Result := $FFFF;
    end;
  end;
begin
  destination.Lines.BeginUpdate;
  sourceStream := TMemoryStream.Create;
  try
    Source.Lines.SaveToStream(sourceStream);
    sourceStream.Position := 0;
    destination.MaxLength := destination.MaxLength + sourceStream.Size;
    rtfStream.dwCookie := DWORD(sourceStream);
    rtfStream.dwError := $0000;
    rtfStream.pfnCallback := @EditStreamReader;
    destination.Perform(EM_STREAMIN, SFF_SELECTION or SF_RTF or SFF_PLAINRTF,
      lParam(@rtfStream));
    if rtfStream.dwError <> $0000 then
      zolty := True;
    sourceStream.Free;
    destination.Lines.EndUpdate;
  except
  end;
end;

在form1上创建我有:

On form1 create i had:

RichEdit1.MaxLength:= $ 7FFFFFF0;

RichEdit1.MaxLength := $7FFFFFF0;

在启用范围检查调试器后对此进行了高亮显示:

after enabling Range check debugger highlited this:

destination.MaxLength := destination.MaxLength + sourceStream.Size;

为RichEdit解决的问题删除最大长度。

Removing max length for RichEdit resolved problem. Thanks for Yours help.

推荐答案

调用堆栈表明您已破坏程序其他部分的堆。这就是 SysGetMem 中访问冲突的解释,可能性大于0.999。

The call stack indicates that you have corrupted the heap in some other part of your program. That's the explanation, with probability > 0.999, for an access violation in SysGetMem.

在执行此调用堆栈中的代码之前,您需要查看启动过程中发生的情况。寻找缓冲区溢出,即访问越界数组元素。仅启用不可缺少的功能很可能足以找到程序的缺陷。

You'll need to look at what happens during startup, before the code in this call stack is executed. Look for buffer overruns, that is accessing out-of-bounds array elements. It is very likely that merely enabling the indispensible range checking feature will be enough to locate your program's defect.

这篇关于应用启动时Delphi XE5违反法规的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 10:00