Project

Profile

Help

Revision 85a9912e

Added by Dave Delpratt 5 months ago

Saxon/C Seg Error fixes

View differences:

src/main/c/Saxon.C.API/SaxonProcessor.cpp
277 277

  
278 278
SaxonProcessor::~SaxonProcessor() {
279 279
    clearConfigurationProperties();
280
    SaxonProcessor::sxn_environ->env->DeleteGlobalRef(proc);
280
    if(proc) {
281
    	SaxonProcessor::sxn_environ->env->DeleteGlobalRef(proc);
282
    }
281 283
    if (versionStr != nullptr) {
282 284
        delete versionStr;
283 285
    }
......
521 523
    saxonCAPIClass = other.saxonCAPIClass;
522 524
    cwd = other.cwd;
523 525
    proc = SaxonProcessor::sxn_environ->env->NewGlobalRef(other.proc);
524
    //SaxonProcessor::sxn_environ= other.environ;
525 526
    parameters = other.parameters;
526 527
    configProperties = other.configProperties;
527 528
    licensei = other.licensei;
......
535 536
    saxonCAPIClass = other.saxonCAPIClass;
536 537
    cwd = other.cwd;
537 538
    proc = SaxonProcessor::sxn_environ->env->NewGlobalRef(other.proc);
538
    //SaxonProcessor::sxn_environ= other.environ;
539 539
    parameters = other.parameters;
540 540
    configProperties = other.configProperties;
541 541
    licensei = other.licensei;
src/main/c/Saxon.C.API/XdmAtomicValue.cpp
21 21
    }
22 22

  
23 23
    XdmAtomicValue::~XdmAtomicValue(){
24
        std::cerr<<"XdmAtomicValue destructor called ref="<<getRefCount()<<std::endl;
25 24
        if(!valType.empty()) {
26 25
            valType.clear();
27 26
        }
src/main/c/Saxon.C.API/XdmItem.cpp
94 94

  
95 95
XdmItem::~XdmItem() {
96 96
    //decrementRefCount();
97
    std::cerr<<std::endl<<"XdmItem destructor called, refCount"<<getRefCount()<<std::endl;
97
    //std::cerr<<std::endl<<"XdmItem destructor called, refCount"<<getRefCount()<<std::endl;
98 98

  
99 99
    SaxonProcessor::sxn_environ->env->ExceptionDescribe();
100 100

  
101 101
    if(value !=nullptr && SaxonProcessor::jvmCreatedCPP>0) {
102
        std::cout << std::endl << "cpp0-1: DeleteGlobalRef" << std::endl;
103 102
        SaxonProcessor::sxn_environ->env->DeleteGlobalRef(value);
104 103
    }
105
    std::cout << std::endl << "cpp0-1" << std::endl;
106 104
    SaxonProcessor::sxn_environ->env->ExceptionDescribe();
107 105
    if(stringValue.empty()) {
108 106
        stringValue.clear();
src/main/c/Saxon.C.API/XdmNode.h
36 36
	XdmNode(XdmNode *parent, jobject, XDM_NODE_KIND);
37 37

  
38 38
	virtual ~XdmNode() {
39
        std::cerr<<"XdmNode destructor called"<<std::endl;
40 39
		if (getRefCount() <1){
41 40
		    delete baseURI;
42 41
			delete nodeName;
43 42
		}
44 43

  
45 44
		//There might be potential issues with children and attribute node not being deleted when the parent node has been deleted
46
		//we need to track this kind of problem.
47 45
	}
48 46

  
49 47
	virtual bool isAtomic();
src/main/c/Saxon.C.API/XdmValue.cpp
127 127

  
128 128
XdmValue::~XdmValue() {
129 129
	//bool safeToClear = false;
130
	std::cout<<"xdmValue destructor size= "<<values.size()<<" ref="<<getRefCount()<<std::endl;
130
	//std::cout<<"xdmValue destructor size= "<<values.size()<<" ref="<<getRefCount()<<" Pointer = "<<(this)<<std::endl;
131 131
    //if(getRefCount()<1){
132
    std::cout<<"xdmValue destructor refCount="<<getRefCount()<<" values.size="<<values.size()<<std::endl;
133 132
	//proc->env->ReleaseObject
134 133
	if(values.size() > 0) {
135 134
        for (size_t i = 0; i < values.size(); i++) {
136 135
            values[i]->decrementRefCount();
137
            std::cout << "xdmItem (XdmValue destructor) refCount=" << values[i]->getRefCount() << std::endl;
138 136
            if (values[i] != nullptr && values[i]->getRefCount() < 1) {
139 137
                delete values[i];
140 138
            }
......
143 141
    }
144 142
	if (valueType != nullptr) { delete valueType; }
145 143
	if (jValues) {
146
        std::cout<<"xdmValue (jValues) jni"<<getRefCount()<<std::endl;
147 144
		SaxonProcessor::sxn_environ->env->DeleteLocalRef(jValues);
148 145
	}
149 146
	xdmSize = 0;
......
153 150
    if(!toStringValue.empty()) {
154 151
        toStringValue.clear();
155 152
    }
156
    std::cout<<"end - xdmValue destructor refCount="<<getRefCount()<<std::endl;
157 153

  
158 154
}
159 155

  
src/main/c/Saxon.C.API/Xslt30Processor.cpp
139 139

  
140 140

  
141 141
void Xslt30Processor::clearParameters(bool delValues) {
142
    std::cout<<"clearParameter" <<std::endl;
143 142
	if(delValues){
144 143
        for(std::map<std::string, XdmValue*>::iterator itr = parameters.begin(); itr != parameters.end(); itr++){
145 144
            XdmValue * value = itr->second;
146
            std::cout<<"clearParameter cp0" <<"ob ref="<<(value)<<std::endl;
147 145
            if(value != nullptr) {
148
                std::cout<<"clearParameter cp0-1" <<std::endl;
149 146
                value->decrementRefCount();
150 147
#ifdef DEBUG
151 148
                std::cout<<"clearParameter() - XdmValue refCount="<<value->getRefCount()<<std::endl;
......
154 151
                    delete value;
155 152
                }
156 153
            }
157
            std::cout<<"clearParameter cp0-2" <<std::endl;
158 154
        }
159 155

  
160 156
	} else {
161
        std::cout<<"clearParameter cp1-0" <<std::endl;
162
        for(std::map<std::string, XdmValue*>::iterator itr = parameters.begin(); itr != parameters.end(); itr++){
163

  
164
			XdmValue * value = itr->second;
165
            std::cout<<"clearParameter cp1" <<"ob ref="<<(value)<<std::endl;
157
        	for(std::map<std::string, XdmValue*>::iterator itr = parameters.begin(); itr != parameters.end(); itr++){
166 158

  
167
            if(value == NULL) {
168
                std::cout<<"clearParameter cp1-0 after itr NULL found!!!!!" <<std::endl;
169
            }
170
			if(value != nullptr) {
171
                std::cout<<"clearParameter cp1-1" <<std::endl;
172
                value->decrementRefCount();
173
            }
159
			parameters.erase(itr);
174 160
		
175 161
        	}
176 162

  
177 163
	}
178
    std::cout<<"clearParameter cp1" <<std::endl;
179 164
	parameters.clear();
180
    std::cout<<"clearParameter cp2" <<std::endl;
181

  
182 165
	
183 166
}
184 167

  
src/main/c/Saxon.C.API/XsltExecutable.cpp
255 255

  
256 256
    } else {
257 257
        for (std::map<std::string, XdmValue *>::iterator itr = parameters.begin(); itr != parameters.end(); itr++) {
258

  
259
            XdmValue *value = itr->second;
260
            if(value != nullptr) {
258
            parameters.erase(itr);
259
            /*if(value != NULL) {
261 260
                value->decrementRefCount();
262
            }
261
            }*/
263 262

  
264 263
        }
265 264

  
266 265
    }
267 266
    parameters.clear();
268 267

  
269

  
270 268
}
271 269

  
272 270
void XsltExecutable::clearProperties() {
src/main/c/samples/cppTests/testXSLT30.cpp
1578 1578
	
1579 1579
    testTransformFromstring(processor, trans, sresult);
1580 1580

  
1581
    processor->release();
1581
    //processor->release();
1582 1582
    delete processor;
1583
    processor->release();
1583 1584
    return 0;
1584 1585

  
1585 1586
    testTransformFromstring2Err(processor, trans, sresult);

Also available in: Unified diff