System.AccessViolationException using PXCV_DrawPageToDIBSect

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
Max SAG
User
Posts: 27
Joined: Thu Oct 30, 2014 8:54 am

System.AccessViolationException using PXCV_DrawPageToDIBSect

Post 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
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Post 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
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3549
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Post 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...
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
Max SAG
User
Posts: 27
Joined: Thu Oct 30, 2014 8:54 am

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Post 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
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Post 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
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3549
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Post 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.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
Max SAG
User
Posts: 27
Joined: Thu Oct 30, 2014 8:54 am

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Post 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
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Post 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
Max SAG
User
Posts: 27
Joined: Thu Oct 30, 2014 8:54 am

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Post 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
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3549
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Post 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.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
Max SAG
User
Posts: 27
Joined: Thu Oct 30, 2014 8:54 am

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Post 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
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3549
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Post by Ivan - Tracker Software »

You can use this one in your production code.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
Max SAG
User
Posts: 27
Joined: Thu Oct 30, 2014 8:54 am

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Post 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
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Post 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,
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
Max SAG
User
Posts: 27
Joined: Thu Oct 30, 2014 8:54 am

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Post by Max SAG »

Hi Will,

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

Best regards,

Max
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: System.AccessViolationException using PXCV_DrawPageToDIB

Post 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,
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
Post Reply