Page 1 of 1

System.AccessViolationException using PXCV_DrawPageToDIBSect

Posted: Fri Dec 16, 2016 9:43 am
by Max SAG
Hi,

I encounter an issue with the PXCV_DrawPageToDIBSect (pxcview.dll v2.5.311.0) method in a WPF project (C#, .NET 4.0). If I call the method in two different threads in parallel on a complex documents and its copy (let's say pdfDocument.pdf and pdfDocument - Copy.pdf, an AccessViolationException is thrown:

System.AccessViolationException was unhandled
HResult=-2147467261
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

I think it comes from the memory used by the library (≈ 800Mo for each document). If I wait for the first call to end and free the resources before the second call, I do not encounter the problem. If I use a lighter document, I do not encounter the problem.

So my questions are :
- Is there a way to lower the amount of memory used?
- Is there a way to get an error code instead of a AccessViolationException, which cannot be handled easily?

Best regards,

Max

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Posted: Tue Dec 20, 2016 3:10 pm
by Tracker Supp-Stefan
Hi Max,

I've passed your post to a colleague that worked on the Viewer SDK, and he will advise here as soon as possible.

Regards,
Stefan

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Posted: Tue Dec 20, 2016 7:41 pm
by Ivan - Tracker Software
- Is there a way to lower the amount of memory used?
It depends on the documents you are working with, and the way you do this. Can you please send us your sample app that demonstrates the problem?
- Is there a way to get an error code instead of a AccessViolationException, which cannot be handled easily?
The function exported by the DLL return an error code as HRESULT, and it does not fire exception. It is the .NET runtime that generates exception based on the function's result. You may use the try/catch brackets to avoid generating exceptions...

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Posted: Fri Dec 23, 2016 9:43 am
by Max SAG
Hi Ivan,

Thank you for your answer.
Can you please send us your sample app that demonstrates the problem?
I have made a sample you can try right here: https://sgmail.scriptandgo.com/owncloud ... zRVbgKo21F
Can I send you the password for the download and the archive by mail, because the sample contains a customer PDF document I don't want to go public? The archive contains the Visual Studio solution and the binaries. To reproduce the problem, try clicking three times on the "Render" button. It will start three threads, each of them will try to draw a part of a copy of the same PDF document.
In my case, if I wait for the previous draw to finish, I do not encounter the problem. If I start three draws at the same time I encounter the AccessViolationException.
You may use the try/catch brackets to avoid generating exceptions...
I know it could be possible to catch the exception, but it doesn't really make sense, as it indicates a corrupted state. There is no guarantee the program will run normally after it. I see no reason to catch the exception rather than log trace.

Best regards,

Max

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Posted: Fri Dec 23, 2016 10:42 am
by Tracker Supp-Stefan
Hello Max,

Please send the password to support@pdf-xchange.com and I will pass it to Ivan.

Happy Holidays,
Stefan

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Posted: Fri Dec 23, 2016 8:25 pm
by Ivan - Tracker Software
As I see the problem is because the process cannot allocate memory because parsed content uses too much memory in this document.
And there are some issues with handling this situation that causes the Access Violation exception you got. I will try to fix these issues in the next build. Also, you can use PDF Editor Simple DLL (here is the DLL with the latest fixes: http://www.docu-track.com/SimpleEditorDLL_20161223.zip). It uses much less memory for parsing PDFs. You can use it as a simple replacement for old PDF Viewer Simple DLL - just rename corresponding DLL file (x64 or x86) to pxcview.dll.

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Posted: Wed Jan 04, 2017 9:23 am
by Max SAG
Hi Ivan,

Thank you for your time. I have just returned from holidays and I can't download the PDF Editor Simple DLL you sent me anymore. Should I try the current version (6.0.319.0) available on the website: https://www.pdf-xchange.com/produc ... simple-sdk ? I don't think that we have the license for it, but I can give it a try.

Best regards,

Max

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Posted: Wed Jan 04, 2017 11:23 am
by Tracker Supp-Stefan
Hello Max,

I just tried the link - and indeed it seems the file is no longer there.
Please try the nightly builds:
https://forum.pdf-xchange.com/ ... 66&t=25943
And let us know if that solves the issue!

Regards,
Stefan

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Posted: Wed Jan 04, 2017 4:43 pm
by Max SAG
Hi,

Thank your for the link, I downloaded the PDFXEditCore.x86.dll from the DevRelease.x32 and renamed it pxcview.dll. I can call the PXCV_DrawPageToDIBSection method but it always return the following error code: -2113732607, which I cannot find in the list of the known errors list. I think you can reproduce it with my sample.

Am I missing something?

Best regards,

Max

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Posted: Wed Jan 04, 2017 5:55 pm
by Ivan - Tracker Software
Thank your for the link, I downloaded the PDFXEditCore.x86.dll from the DevRelease.x32 and renamed it pxcview.dll. I can call the PXCV_DrawPageToDIBSection method but it always return the following error code: -2113732607, which I cannot find in the list of the known errors list. I think you can reproduce it with my sample.
PDFXEditCore.x86.dll does not export PXCV_DrawPageToDIBSection. Maybe you mean PDFXEditSimple.x86.dll ? If yes, please download fixed version from http://www.docu-track.co.uk/SimpleEdito ... 161223.zip which should fix the problem.

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Posted: Thu Jan 05, 2017 8:07 am
by Max SAG
Hi Ivan,

Sorry yes, I mean PDFXEditSimple.x86.dll. Indeed, the fixed version is working well. I do not encounter the AccessViolationException anymore, it consumes much less memory than the one I used and seems a lot faster. Should I wait for the official release to include it in our project or should I use the one you send me?

Best regards,

Max

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Posted: Thu Jan 05, 2017 6:44 pm
by Ivan - Tracker Software
You can use this one in your production code.

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Posted: Fri Jan 20, 2017 3:46 pm
by Max SAG
Hi,

I noticed that our license for the Viewer Simple DLL SDK does not work with the (fixed) PDF Editor Simple SDK. So we can't use it in our products. Do you plan to apply the correction to the Viewer Simple DLL SDK?

Best regards,

Max

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Posted: Fri Jan 20, 2017 4:09 pm
by Will - Tracker Supp
Hi Max,

The Viewer SDK is no longer being actively updated, with the potential exception of security fixes. The Viewer SDK can still be purchased, but users do so with the understanding that it is to be purchased 'as-is'.

Thanks,

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Posted: Fri Jan 20, 2017 4:36 pm
by Max SAG
Hi Will,

Thanks for the quick answer, I'll check with my boss and the Tracker sales service.

Best regards,

Max

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Posted: Sat Jan 21, 2017 6:49 pm
by Will - Tracker Supp
No worries Max, glad to help! :) Just a note, if you weren't already planning on doing so; if you do have any sales related questions, it's best to send them directly to sales@pdf-xchange.com.

Cheers,