Ticket #1400 (closed defect: fixed)

Opened 5 years ago

Last modified 2 years ago

layerObj.delete() crashes in Java/MapScript

Reported by: umn-ms@hydrotec.de Assigned to: sdlime
Priority: high Milestone:
Component: MapScript-SWIG Version: 4.6
Severity: normal Keywords:
Cc:

Description (Last modified by hobu)

Thread "Java VM Crashes using the Mapscript API" in Mapserver-users-List

Christian reported a crash in layerObj.delete() which I 
also detected. 
I think I understood the following: 

Let's say, we have an initialized  mapObj mO; 

layerObj lO = new layerObj(mO); 
// Say lO is the 5th layer now. 
// Now lO.swigCMemOwn == true and 
//     lO.swigCPtr points onto the mO.swigCPtr->layers[4] 

... 
// now the mapObj is deleted but the Java-layerObj continues to live. 
// the C-layer-Object mO.swigCPtr->layers[4] will deleted and freed also! 
mO.delete() 
// From now on O.swigCPtr points into invalid piece of C-memory. 
... 

Later on the Java-garbage-collector finalizes the layerObj. 

Because of "lO.swigCMemOwn == true" and "lO.swigCPtr!=0" the finalize-method calls 
layerObj.delete(). This method frees lO.swigCPtr which is invalid memory. 

Same story about layerObj/classObj.

Change History

06/28/05 12:26:29 changed by sdlime

  • component changed from MapScript to MapScript-SWIG.

06/16/06 19:18:49 changed by szekerest

This bug was fixed for C# in

http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=1743

I will look after how to fix it generally for mapscript.

Tamas

12/04/06 03:31:41 changed by unicoletti

  • cc set to unicoletti@prometeo.it.

(follow-up: ↓ 5 ) 05/22/07 18:12:18 changed by hobu

  • description changed.

What is the status on this one now that RFC 24 is in place?

(in reply to: ↑ 4 ) 05/23/07 03:06:02 changed by unicoletti

Replying to hobu:

What is the status on this one now that RFC 24 is in place?

It should be fixed, but I'm waiting to add another couple of features to rfc24 before closing it.

12/17/07 08:29:29 changed by unicoletti

  • status changed from new to closed.
  • resolution set to fixed.

Fixed by RFC-24, closing