|
Rank: Newbie Groups: Member
Joined: 7/13/2012 Posts: 5
|
I have been testing your HtmlToPdf conversion tool for use in a solution I am working on. I need to use the tool in a multi-threaded windows service, but I ran conversions in a console application for testing purposes. The solution I am working on reads data from a database and generates html on request. Each request typically consists of quite a few html documents (an average of perhaps 200-400) of varying size and complexity. I loop through the documents and convert each to pdf, then examine the results object for certain known Element IDs. When I find the Element IDs (if they exist), I save their location for use later. I do not try to write to the request object or even to the generated PDF at this point. The PDF is saved, and I am done with the EO.Pdf assembly. For each request, this process happens several hundred times in succession.
I am using build 4.0.25.2
Testing was going very well until I built the tool into a test service. I never saw any errors when running the process via a console application. However, when I call ConvertHtml inside the service, every so often, the following exception is thrown:
[System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at EO.Pdf.Internal.df.aq.Invoke(IntPtr A_0, String A_1) at EO.Pdf.Internal.df.b(IntPtr A_0) at EO.Pdf.Internal.df.a(g A_0, Int32 A_1, Int32 A_2, Int32 A_3) at EO.Pdf.Internal.df.m.Invoke(IntPtr A_0, String A_1, String A_2, Boolean A_3) at EO.Pdf.Internal.df.a(String A_0, Boolean A_1, String[] A_2, Byte[] A_3) at EO.Pdf.Internal.df.a(String A_0, Boolean A_1, Boolean A_2, Int32 A_3, t A_4, String[] A_5, Byte[] A_6, h0 A_7) at EO.Pdf.Internal.df.a(HtmlToPdfOptions A_0, String A_1, Boolean A_2) at EO.Pdf.Internal.df.b(HtmlToPdfOptions A_0, String A_1, Boolean A_2) at EO.Pdf.Internal.df.a(hi A_0) at EO.Pdf.Internal.lo.c.a(hi A_0) at EO.Pdf.Internal.lo.c.a(Byte[] A_0)]]
So far, the exception has been unpredictable. It happens at different points in the process and with different generated html documents each time. Any insight into the problem and possible solutions would be greatly appreciated.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
We are not exactly sure what's the root cause unless we have a way to reproduce it. However we run the actual conversion inside a different process, and that process is isolated from your process. Exceptions are propagated back to your process from that process. That means even if you get such error, your own process is still fine. So one temporary solution is to use a try catch to catch the exception and try again to see if it goes through.
In order to permanently resolve this issue, we have to be able to reproduce it first. So if you have a way to reproduce it (even even not consistently), please let us know. Usually as soon as we can reproduce it, we will be able to get to the bottom of it.
We are not aware of any significant difference between a service process and a console process except for the user account difference. The user account would have an impact on permissions as well as Windows authentications.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 7/13/2012 Posts: 5
|
I have been working on a project to emulate the service we are building, and so far I have not been able to reproduce the exact error we are trying to resolve here. However, in the project I have built, I do receive a different error once I begin threading requests. When I run 9 threads, I very quickly get an IndexOutOfRangeException. (Stack trace below). I would be happy to zip the project up and send it to you for review; perhaps the errors are related. The solution has both a console app and a service, and both produce the same exception.
I am using the latest build as of last Friday. I am still trying to reproduce the AccessViolationException.
Stack trace from the error above: System.ArgumentException occurred Message=Source array was not long enough. Check srcIndex and length, and the array's lower bounds. ParamName="" Source=mscorlib StackTrace: at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable) at System.Collections.Generic.Dictionary`2.Resize() at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value) at EO.Pdf.Internal.mp.a(Int32 A_0, Single A_1) at EO.Pdf.Internal.gf.a(Int32 A_0) at EO.Pdf.Internal.ev.a.a(i2 A_0) at EO.Pdf.Internal.ev.a(gf A_0, i2 A_1) at EO.Pdf.Contents.PdfTextContent.a(br A_0) at EO.Pdf.Contents.PdfContent.b(br A_0) at EO.Pdf.Contents.PdfContent.a(br A_0) at EO.Pdf.Contents.PdfTextLayer.a(br A_0) at EO.Pdf.Contents.PdfContent.b(br A_0) at EO.Pdf.Contents.PdfContent.a(br A_0) at EO.Pdf.Contents.PdfContent.b(br A_0) at EO.Pdf.Contents.PdfContentContainer.i() at EO.Pdf.PdfDocument.a() at EO.Pdf.PdfDocument.Save(String fileName) at IppEmulationClasses.CIppEmulator.Emulate() in C:\MISC\IPPEmulation\IppEmulationClasses\IppEmulationClasses\CIppEmulator.vb:line 77 InnerException:
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
That looks very much like a multi-threading issue since it crashes MS's code. It appears that Dictionary that throws out this error was modified by multi-threads while it should not have been.
This can be an error in your code or in our code. For example, if you share a single PdfDocument objects through multi-thread, then you can run into this problem very easily since you are not suppose to do that. If you have ensured that you are not sharing, or have correctly synchronized all access to shared variables in your code, then it might be an issue in our code, where we should have synchronized access to shared variables in our code but we didn't do so. In that case you can send the test app that you use to reproduce the problem and we will be happy to investigate further. We will PM you as to where to send it.
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
Please download the latest build from our download page (4.0.29.2) and see if that fixes the problem for you. We did fix one threading issue recently but we have not seen it causing the error you posted. However we have not been able to reproduce the problem with the test app you sent to us on build .29.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 7/13/2012 Posts: 5
|
Sorry, I should have specified- I am using 4.0.29.2 already.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Then we are having a little trouble here ---- your test app is still running with no problems. We will try to run it on a different machine and see if it gives us a different result. We will have to see the problem in order to find out exactly what's causing it.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 7/13/2012 Posts: 5
|
Yeah, that is somehow not surprising. I have really been struggling trying to make the emulator throw the original exception, but without much luck so far.
You might try bumping up the number of threads. I encountered the error as I scaled up, though on a different machine, we saw the same problem with only two threads. Currently, when the console app starts, it passes a hard-coded 9 into the constructor for a class that acts as a thread manager. Changing that alters the number of threads the emulator spins up.
Just a suggestion, though I am guessing you already spotted this.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
Thank you very much for the suggestion. We have reproduced the problem. We are still investigating it but it does appear to be a bug in our code. Once confirmed we should be able to get you a fix either late today or tomorrow.
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
We have fixed the problem and posted a new build for you. Please see your private message for the download location.
Thanks!
|
|