Memory Exception - 64 bit

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics or PDF-XChange Viewer SDK if appropriate.

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

Post Reply
gregc
User
Posts: 5
Joined: Wed Jul 03, 2019 6:54 pm

Memory Exception - 64 bit

Post by gregc » Wed Jul 03, 2019 7:04 pm

We are using the PDF Tools SDK 4 and have been for years now in production code in 64 bit. We have since migrated the application to a new server OS, Windows 2016 server, and now running it in the 64 bit process does not work properly. It worked properly in the 64 bit mode on the old Windows Server 2008 OS, so I am not sure why it will not work on the new OS.

It works fine in a 32 bit process in the new Windows Server 2016 OS, but we are getting the exception below when we attempt to run it in a 64-bit process.

System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

This exception occurs when we call “PDFXC_Funcs.PXC_AddEnhMetafile(pdf, metaFile.GetHenhmetafile(), out image);”.

We have the DLLImport defined as followed:


[DllImport("pxclib40")]
public static extern int PXC_AddEnhMetafile(int pdf, IntPtr metafile, out int image);

Can you shed any light on why we are receiving this exception?

gregc
User
Posts: 5
Joined: Wed Jul 03, 2019 6:54 pm

Re: Memory Exception - 64 bit

Post by gregc » Mon Jul 15, 2019 12:46 pm

I was directed to this forum by the official support team so I am a little confused as to why I wouldn't at least receive some type of response. Is there a way to escalate the issue? Thank you.

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13424
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Memory Exception - 64 bit

Post by Tracker Supp-Stefan » Tue Jul 16, 2019 1:58 pm

Hello Greg C,

Apologies for missing your original post!
I've just passed this forum topic to our devs who were working on the Tools SDK, and we will post again here as soon as I have nay feedback for you!

Regards,
Stefan

gregc
User
Posts: 5
Joined: Wed Jul 03, 2019 6:54 pm

Re: Memory Exception - 64 bit

Post by gregc » Tue Jul 16, 2019 2:11 pm

Thank you Stefan. Like I mentioned before, the code runs fine on the old Windows Server 2008, but not on the new Windows Server 2016.

User avatar
Roman - Tracker Supp
Site Admin
Posts: 268
Joined: Sun Nov 21, 2004 3:19 pm

Re: Memory Exception - 64 bit

Post by Roman - Tracker Supp » Wed Jul 17, 2019 3:56 pm

Hello Greg C,
Can you provide a minimal sample application that reproduces this issue (along with the EMF file)?

Also can you please run the following command from Visual Studio Command Prompt:

Code: Select all

editbin /LARGEADDRESSAWARE:NO /HIGHENTROPYVA:NO <your application exe file>
This command will modify the exe file to possibly workaround this issue.
Tracker Software Products

Please ZIP any files uploaded to this forum or they will not be posted !
You may also use a RAR or 7Z archive format

gregc
User
Posts: 5
Joined: Wed Jul 03, 2019 6:54 pm

Re: Memory Exception - 64 bit

Post by gregc » Fri Jul 19, 2019 2:09 pm

Thank you. Using that EditBin command does make the sample I have work in 64-bit mode, but doesn't setting those values essentially make the 64-bit process operate much like a 32-bit process in the way of potential memory consumption (or lack thereof)?

Also, was that the suggested resolution to the issue or does that now give you guys the information you needed to make an actual fix where that will not be required? Please let me know.

User avatar
Roman - Tracker Supp
Site Admin
Posts: 268
Joined: Sun Nov 21, 2004 3:19 pm

Re: Memory Exception - 64 bit

Post by Roman - Tracker Supp » Fri Jul 19, 2019 2:58 pm

doesn't setting those values essentially make the 64-bit process operate much like a 32-bit process in the way of potential memory consumption (or lack thereof)?
Yes, this will prevent your application from using memory addresses over 2 GB.
was that the suggested resolution to the issue or does that now give you guys the information you needed to make an actual fix where that will not be required?
You can use this for now as a quick workaround.

Can you provide us with a minimal sample application that reproduces this issue (along with the EMF file)?
Tracker Software Products

Please ZIP any files uploaded to this forum or they will not be posted !
You may also use a RAR or 7Z archive format

gregc
User
Posts: 5
Joined: Wed Jul 03, 2019 6:54 pm

Re: Memory Exception - 64 bit

Post by gregc » Tue Jul 30, 2019 1:21 pm

Hi Roman, I have a sample that I have attached that exhibits the behavior. Please let me know what you find. Thank you.
Attachments
PdfToolsSDKMemoryException64.7z
(3.72 MiB) Downloaded 6 times

Ivan - Tracker Software
Site Admin
Posts: 3607
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Memory Exception - 64 bit

Post by Ivan - Tracker Software » Wed Jul 31, 2019 4:22 pm

The problem is with declarations of functions exported from the SDK.

For example

Code: Select all

        [DllImport("pxclib40")]
        public static extern int PXC_AddPage(int pdf, double width, double height, out int page);
Type int is 32-bit type, while for 64-bit configuration pdf and page arguments of this function should be 64-bits as they represent pointers to the SDK internal objects.

You should use IntPtr instead of int there.
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.

Post Reply