Unhandled exception inside ocrtools-x64.dll

PDF-X OCR SDK is a New product from us and intended to compliment our existing PDF and Imaging Tools to provide the Developer with an expanding set of professional tools for Optical Character Recognition tasks

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

Post Reply
eric_hill
User
Posts: 16
Joined: Tue Mar 28, 2006 12:40 am

Unhandled exception inside ocrtools-x64.dll

Post by eric_hill » Fri Jul 22, 2016 1:22 pm

I'm using Visual Studio Community 2015 to build a 64-bit app that will OCR some PDF's through a scanning pipeline. I'm getting an unhandled exception during the OCR_LoadW call, and I can't seem to get by it. Short version of the code is:

Code: Select all

int main(int argc, char** argv) {
	if (argc < 3) {
		cout << "Both an input and output file must be specified on the command line" << endl;
		return 0;
	}

	DWORD maxLevel;
	PXODocument doc; ZeroMemory(&doc, sizeof(PXODocument));
	HRESULT r;

	r = OCR_Init(&doc, oldLicense, oldLicenseDev);
	if (IS_DS_FAILED(r)) {
		cout << "Failed to initialize OCR engine" << endl;
		return -1;
	}

	r = OCR_SetCallback(&doc, &ocrCallback, (LPARAM)&maxLevel);
	if (IS_DS_FAILED(r)) {
		cout << "Failed to define callback procedure" << endl;
		return -1;
	}
	
	string src(argv[1]);
	wstring wsrc(src.begin(), src.end());
	r = OCR_LoadW(doc, (LPWSTR)(wsrc.c_str())); // <- Exception occurs here
	if (IS_DS_FAILED(r)) {
		cout << "Unable to load " << argv[1] << endl;
		return -1;
	}
The exception is:

Code: Select all

Exception thrown at 0x000007FED16B104F (ocrtools-x64.dll) in pxpocr.exe: 0xC0000005: Access violation reading location 0x00000F00E90000FE.
Unhandled exception at 0x000007FED16B104F (ocrtools-x64.dll) in pxpocr.exe: 0xC0000005: Access violation reading location 0x00000F00E90000FE.

eric_hill
User
Posts: 16
Joined: Tue Mar 28, 2006 12:40 am

Re: Unhandled exception inside ocrtools-x64.dll

Post by eric_hill » Mon Jul 25, 2016 12:45 pm

Found the issue:

Code: Select all

int main(int argc, char** argv) {
   if (argc < 3) {
      cout << "Both an input and output file must be specified on the command line" << endl;
      return 0;
   }

   DWORD maxLevel;
   PXODocument doc; ZeroMemory(&doc, sizeof(PXODocument));
   HRESULT r;

   r = OCR_Init(&doc, oldLicense, oldLicenseDev);
   if (IS_DS_FAILED(r)) {
      cout << "Failed to initialize OCR engine" << endl;
      return -1;
   }

   r = OCR_SetCallback(&doc, &ocrCallback, (LPARAM)&maxLevel); // Should be doc, not &doc
   if (IS_DS_FAILED(r)) {
      cout << "Failed to define callback procedure" << endl;
      return -1;
   }
   
   string src(argv[1]);
   wstring wsrc(src.begin(), src.end());
   r = OCR_LoadW(doc, (LPWSTR)(wsrc.c_str())); // <- Exception occurs here
   if (IS_DS_FAILED(r)) {
      cout << "Unable to load " << argv[1] << endl;
      return -1;
   }
The compiler doesn't differentiate between a PXODocument and *PXODocument because PXODocument is a void*. You have to turn the compiler warnings up a couple of clicks to get a warning about the mis-use of the pointer.

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

Re: Unhandled exception inside ocrtools-x64.dll

Post by Will - Tracker Supp » Mon Jul 25, 2016 6:50 pm

Hi Eric,

Thanks for the posts - is all working as expected now?

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