The thread attempted to read from or write to a virtual address for which it does not have access.

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, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
wayne w
User
Posts: 5
Joined: Tue Nov 12, 2019 11:03 pm

The thread attempted to read from or write to a virtual address for which it does not have access.

Post by wayne w »

Exception raised:
[pxclib40].PXC_Choice_AddItem
[pxclib40].DS_PXCLib::UrlVector::~UrlVector
[gdi32full].EnumEnhMetaFile
[GDI32].EnumEnhMetaFile
[pxclib40].DS_PXCLib::UrlVector::~UrlVector
[pxclib40].DVector<DS_PXCLib::tagUrlVariant *,-2>::pop_back
[GDI32].EnumFontFamiliesExA
[ucrtbase].chmod
[GDI32].gW32PID

This happens on some of the machines. Normally a reboot of Windows will fix the problem for a little while, but it will happen again. In some cases, a reboot will only stop the exception for 49 minutes.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17810
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: The thread attempted to read from or write to a virtual address for which it does not have access.

Post by Tracker Supp-Stefan »

Hello Wayne,

Can you please check and let us know which build of the dlls is currently used?
Have you tried with the latest available?
Also - is this happening on a machine where e.g. you are trying to process multiple files at a time (could you be reaching some memory limits)?

Regards,
Stefan
wayne w
User
Posts: 5
Joined: Tue Nov 12, 2019 11:03 pm

Re: The thread attempted to read from or write to a virtual address for which it does not have access.

Post by wayne w »

Thanks Stefan for the reply. The version we are using is 4.0.211.0. The library is used to convert HMETAFILE to PDF. There could be multiple pages in the WMF meta file, but it's only a single task at a time and the files are small in size ( a few Mega Bytes).

Are there any known issues around the memory leak fixes in this area in a later release? This happens a lot in the production environment. We haven't been able to reproduce in development and haven't tried with the later release builds.
Attachments
image.png
image.png (12.84 KiB) Viewed 6719 times
image.png
image.png (12.84 KiB) Viewed 6719 times
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17810
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: The thread attempted to read from or write to a virtual address for which it does not have access.

Post by Tracker Supp-Stefan »

Hello Wayne,

Build 211 is quite old - some 6 years now.
Are you just starting working with the SDK, or have you been using it for years and only recently it started causing those issues?

The last V4 build of the Tools SDK is 4.0.315:
https://www.pdf-xchange.com/downloads/PDFT4SDK.zip
So please try using these DLLs and see if that helps!

Regards,
Stefan
wayne w
User
Posts: 5
Joined: Tue Nov 12, 2019 11:03 pm

Re: The thread attempted to read from or write to a virtual address for which it does not have access.

Post by wayne w »

Thanks Stefan, we'll update to the later build. It will take some time to find out if it will make a difference, will update once we have the feedback.
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom
Contact:

Re: The thread attempted to read from or write to a virtual address for which it does not have access.

Post by John - Tracker Supp »

(y) Thanks Wayne.
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
Tracker Support
http://www.tracker-software.com
wayne w
User
Posts: 5
Joined: Tue Nov 12, 2019 11:03 pm

Re: The thread attempted to read from or write to a virtual address for which it does not have access.

Post by wayne w »

Unfortunately the later build on 4.0.315 still has the issue. Now I've figured out it's because of leaks of GDI resources. We use the PDF-Tools to convert from meta data WMF to a PDF file. The code looks pretty much like this:
_PXCDocument* pdf = NULL;
HRESULT hr = PXC_NewDocument(&pdf, TRACKER_SERIAL_NUMBER, TRACKER_DEVELOPMENT_CODE);
if(IS_DS_SUCCESSFUL(hr))
{
_PXCImage *image = NULL;
hr = PXC_AddStdMetafile(pdf, hmf, &image);
if(IS_DS_SUCCESSFUL(hr))
{
_PXCPage* page;
hr = PXC_AddPage(pdf, TENTH_MILLIMETER_TO_POINT(m_PageWidth), TENTH_MILLIMETER_TO_POINT(m_PageHeight), &page);
if(IS_DS_SUCCESSFUL(hr))
{
hr = PXC_GetImageDimension(pdf, image, &imageWidth, &imageHeight);
if(IS_DS_SUCCESSFUL(hr))
{
hr = PXC_PlaceImage(page, image, x, y, imageWidth, imageHeight);
}
PXC_EndPage(page);
}
PXC_CloseImage(pdf, image);
}
}
PXC_ReleaseDocument(pdf);

Depending on the contents in the meta file, each run will leak 200-300 GDI objects. By time it will reach the default limit of 10,000 in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\GDIProcessHandleQuota. From there we get the problems.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17810
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: The thread attempted to read from or write to a virtual address for which it does not have access.

Post by Tracker Supp-Stefan »

Hello Wayne,

A colleague in the dev team asked if you could provide us with sample EMFs which cause the issue?
We won't be able to fix the issue in build 315.
The current PDF Tools build is 4.0.0321.0 so we can make a new 4.0.0321.1 with the fix included.

Regards,
Stefan
wayne w
User
Posts: 5
Joined: Tue Nov 12, 2019 11:03 pm

Re: The thread attempted to read from or write to a virtual address for which it does not have access.

Post by wayne w »

Thanks Stefan, it's false alarm. We have now identified the cause of the leak. It was actually from when the meta file was generated, and the PDF converter just doubled on the leaked handles. Once the leak is stopped at the time of creating the meta file, the converter works perfect.

Thanks a lot for the help. Tracker tools is really great product.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17810
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: The thread attempted to read from or write to a virtual address for which it does not have access.

Post by Tracker Supp-Stefan »

Hello wayne w,

Glad to hear you've figured it out and many thanks for the kind words!

Cheers,
Stefan
Post Reply