Bug #5429
closedwhen using no argument with new SaxonProcessor(), further code gives access violation
100%
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)?
Updated by Martin Honnen over 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.
Updated by Martin Honnen over 2 years ago
Under Linux I get "Error: Saxonc. getProductVersion() not found".
Updated by O'Neil Delpratt over 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.
Updated by O'Neil Delpratt over 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).
Updated by O'Neil Delpratt over 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.
Updated by O'Neil Delpratt over 2 years 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