Free Support Forum - aspose.com

Endless loop in ProcessParagraphs


#1

I continually am hitting this problem while trialing your Aspose.PDF library - there is a bug that causes an endless loop which is potentially fatal to a web server and I’ve isolated it - it can be reproduced with the following code:

		Document d = new Document();
		Page p = d.Pages.Add();
		Table t = new Table();
		t.Broken = TableBroken.Vertical;
		p.Paragraphs.Add(t);
		Aspose.Pdf.Row r = t.Rows.Add();
		Aspose.Pdf.Cell c = r.Cells.Add("abc");
		MarginInfo m = new MarginInfo();
		m.Top = 1000;
		c.Margin = m;
		d.ProcessParagraphs();

#2

@jedwards

Thank you for contacting support.

Please note that the default page size in Aspose.PDF API is A4 page size, that makes 595x842 points where 72 points equal 1 inch. Therefore, when you are setting the margin of cell larger than page size then reported problem occurs. You may avoid the problem by keeping a check that margin never exceeds page height.

Below code snippet is exact copy of your code except different page size and the problem does not occur anymore.

Document d = new Document();
Page p = d.Pages.Add();
p.PageInfo.Height = 1200;
Table t = new Table();
t.Broken = TableBroken.Vertical;
p.Paragraphs.Add(t);
Aspose.Pdf.Row r = t.Rows.Add();
Aspose.Pdf.Cell c = r.Cells.Add("abc");
MarginInfo m = new MarginInfo();
m.Top = 1000;
c.Margin = m;
d.ProcessParagraphs();

We hope this will be helpful. Please feel free to contact us if you need any further assistance.


#3

Hi Farhan, no that is not helpful at all. This was the simplest example I could make to demonstrate the problem to allow you to identify it and fix. This doesn’t cause an exception to be thrown - it literally brings the development server down, and if I put code into production it would bring the live server down. You have a serious bug in your library that needs to be fixed.

There are other ways this bug occurs such as with nested tables with an innermost cell which is larger than a page height. I gave you the above code so you could quickly start debugging and see the cause - it seems to be a bug to do with an endless loop when attempting to calculate flow of large content over multiple pages.

Can you please actually investigate this.


#4

@jedwards

Thank you for elaborating it further.

We have logged a ticket with ID PDFNET-46385 in our issue management system for further investigations. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.