Project

Profile

Help

Bug #5429

closed

when using no argument with new SaxonProcessor(), further code gives access violation

Added by Martin Honnen about 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Category:
C++ API
Start date:
2022-03-28
Due date:
% Done:

100%

Estimated time:
Found in version:
11.2
Fixed in version:
11.4
Platforms:

Description

Following up on https://saxonica.plan.io/boards/4/topics/8665 where I thought my trouble to get Saxon C HE 11.2 inside of a Notepad++ plugin were related to the environment I used it in I wrote a console app to see whether perhaps the proble exists there as well, and indeed, for me, on Windows at least, a simple console application using no argument to the SaxonProcessor constructor (https://www.saxonica.com/saxon-c/doc11/html/classSaxonProcessor.html#a5e96005ddffc24afef80bdc5714cb544)

crashes with

Exception thrown at 0x0000000000452014 (libsaxonhec.dll) in SaxonCArgumentLessConstructorTest.exe: 0xC0000005: Access violation reading location 0x0000000000000067.

#include

#include "SaxonProcessor.h"

#include <iostream>

#include "SaxonProcessor.h"


int main()
{
    std::cout << "Hello World!\n";

    SaxonProcessor* saxonProc = new SaxonProcessor();

    const char* version = saxonProc->version();

    std::cout << version << "\n";

    saxonProc->release();

    delete saxonProc;
}

Isn't that argument constructor meant to simply call new SaxonProcessor(false)?

Actions #1

Updated by Martin Honnen about 2 years ago

Just tested with 11.3 HE, get the same access violation:

Exception thrown at 0x0000000000452014 (libsaxonhec.dll) in SaxonC113ArgumentLessConstructorTest.exe: 0xC0000005: Access violation reading location 0x0000000000000067.
Actions #2

Updated by Martin Honnen about 2 years ago

Under Linux I get "Error: Saxonc. getProductVersion() not found".

Actions #3

Updated by O'Neil Delpratt about 2 years ago

  • Status changed from New to In Progress

Thanks for reporting this issue. I have reproduced it and it is a bug.

I would have thought the no argument constructor would be calling SaxonProcessor(false), but it looks like something strange is going on.

The workaround is just to call the constructor with the license boolean flag.

Actions #4

Updated by O'Neil Delpratt about 2 years ago

It is not possible to call a constructor from another constructor in C++. C++11 does allow constructors to call other peer constructors (known as delegation).

Actions #5

Updated by O'Neil Delpratt about 2 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 0 to 100

I have committed a fix in the C++ files SaxonProcessor.h and SaxonProcessor.cpp. The fix was to create a initialise() method which then gets called by the constructors.

Actions #6

Updated by O'Neil Delpratt over 1 year ago

  • Status changed from Resolved to Closed
  • Fixed in version set to 11.4

Bug fix applied in the SaxonC 11.4 maintenance release.

Please register to edit this issue

Also available in: Atom PDF