开发者

QuickReport.ExportToFilter throws "stack overflow" error when used in TWebModule

I have a web application using the TWebModule component. It runs as a module on Apache. The code below throws a "St开发者_开发知识库ack Overflow" error on the ExportToFilter. The same exact code works fine from a Winforms Application and even a service for that matter. I have seen other discussions on this which indicate it has something to do with threading.

var
  mFileName: String;
  AExportFilter:;
begin
    mFileName := 'c:\temp\calendar.pdf';
    AExportFilter:=TQRPDFDocumentFilter.Create(mFileName);
    try

      WebSchdHistCalendarForm := TWebSchdHistCalendarForm.create(nil);
      WebSchdHistCalendarForm.quickrep1.ShowProgress := False;
      WebSchdHistCalendarForm.quickrep1.ExportToFilter(AExportFilter  );
    finally
     AExportFilter.Free;
     WebSchdHistCalendarForm.Free;
    end;


If I'm not mistaken you get Stack overflow on infinite recursive method calls. This might not be the case here though.


Only 11 years late, but this might be useful to someone else, as I've just encountered this problem with one of my applications running on some Windows 10 machines.

(Actually in my case the Windows event log reported it as an access violation, but by running WinDbg on one of the problem machines I was able to see the initial cause was a stack overflow at the cvtInt() function.)

The fix is to mark the Buf parameter as const in a couple of functions in QRPDFFilt.pas:

function cvtInt(Buf: array of byte; P: Integer) : Integer;
begin
  Result:=(256*Buf[P])+(Buf[P+1]);
end;

should be:

function cvtInt(const Buf: array of byte; P: Integer) : Integer;
begin
  Result:=(256*Buf[P])+(Buf[P+1]);
end;

and likewise for cvtDWord():

function cvtDWord(const Buf: array of byte; P: Integer) : DWORD;

(Thanks to Marco Filho for this solution, found on devmedia.com.br)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜