[mapguide-commits] r10263 - in branches/4.0/MgDev/Portable/MgPortable/Services: . Feature Feature/Commands

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Nov 3 06:32:36 PST 2026


Author: jng
Date: 2026-11-03 06:32:34 -0800 (Tue, 03 Nov 2026)
New Revision: 10263

Modified:
   branches/4.0/MgDev/Portable/MgPortable/Services/Feature/Commands/UpdateFeatures.cpp
   branches/4.0/MgDev/Portable/MgPortable/Services/Feature/FdoForcedOneToOneFeatureReader.cpp
   branches/4.0/MgDev/Portable/MgPortable/Services/Feature/FeatureConnection.cpp
   branches/4.0/MgDev/Portable/MgPortable/Services/Feature/FeatureUtil.cpp
   branches/4.0/MgDev/Portable/MgPortable/Services/Feature/GwsConnectionPool.cpp
   branches/4.0/MgDev/Portable/MgPortable/Services/Feature/JoinFeatureReader.cpp
   branches/4.0/MgDev/Portable/MgPortable/Services/Feature/JoinFeatureReader.h
   branches/4.0/MgDev/Portable/MgPortable/Services/ScrollableFeatureReader.cpp
Log:
#2897: Plug ASAN reported leaks in MapGuide Portable

Modified: branches/4.0/MgDev/Portable/MgPortable/Services/Feature/Commands/UpdateFeatures.cpp
===================================================================
--- branches/4.0/MgDev/Portable/MgPortable/Services/Feature/Commands/UpdateFeatures.cpp	2026-11-03 13:53:48 UTC (rev 10262)
+++ branches/4.0/MgDev/Portable/MgPortable/Services/Feature/Commands/UpdateFeatures.cpp	2026-11-03 14:32:34 UTC (rev 10263)
@@ -59,7 +59,7 @@
                                                       bool useTransaction)
 {
     Ptr<MgPropertyCollection> propCol;
-    FdoITransaction* transaction = NULL;
+    FdoPtr<FdoITransaction> transaction;
     bool commited = false;
 
     MG_FEATURE_SERVICE_TRY()

Modified: branches/4.0/MgDev/Portable/MgPortable/Services/Feature/FdoForcedOneToOneFeatureReader.cpp
===================================================================
--- branches/4.0/MgDev/Portable/MgPortable/Services/Feature/FdoForcedOneToOneFeatureReader.cpp	2026-11-03 13:53:48 UTC (rev 10262)
+++ branches/4.0/MgDev/Portable/MgPortable/Services/Feature/FdoForcedOneToOneFeatureReader.cpp	2026-11-03 14:32:34 UTC (rev 10263)
@@ -267,7 +267,7 @@
         bool append = false;
         wchar_t tbuff[256];
         //Don't bother with IsNull() checks. These are identity property values, how can they be null?
-        FdoStringElement* el = m_idPropNames->GetItem(i);
+        FdoPtr<FdoStringElement> el = m_idPropNames->GetItem(i);
         FdoStringP str = el->GetString();
         FdoString* name = (FdoString*)str;
         

Modified: branches/4.0/MgDev/Portable/MgPortable/Services/Feature/FeatureConnection.cpp
===================================================================
--- branches/4.0/MgDev/Portable/MgPortable/Services/Feature/FeatureConnection.cpp	2026-11-03 13:53:48 UTC (rev 10262)
+++ branches/4.0/MgDev/Portable/MgPortable/Services/Feature/FeatureConnection.cpp	2026-11-03 14:32:34 UTC (rev 10263)
@@ -91,6 +91,8 @@
         FdoInt32 iRefCount = m_fdoConn->GetRefCount();
         ACE_DEBUG((LM_INFO, ACE_TEXT("MgPortableFeatureConnection::Close() - refcount %d\n"), iRefCount));
     #endif
+        // ReturnConnection takes over this object's reference to the connection: it either
+        // hands it to the pool (which holds its own reference) or closes it and releases it.
         MgPortableFdoConnectionPool::ReturnConnection(this);
         m_fdoConn = NULL;
     }

Modified: branches/4.0/MgDev/Portable/MgPortable/Services/Feature/FeatureUtil.cpp
===================================================================
--- branches/4.0/MgDev/Portable/MgPortable/Services/Feature/FeatureUtil.cpp	2026-11-03 13:53:48 UTC (rev 10262)
+++ branches/4.0/MgDev/Portable/MgPortable/Services/Feature/FeatureUtil.cpp	2026-11-03 14:32:34 UTC (rev 10263)
@@ -3476,7 +3476,7 @@
     case FdoExpressionItemType_Function:
         {
             FdoFunction* func = static_cast<FdoFunction*>(expr);
-            FdoExpressionCollection* funcArgs = func->GetArguments();
+            FdoPtr<FdoExpressionCollection> funcArgs = func->GetArguments();
             for (FdoInt32 i = 0; i < funcArgs->GetCount(); i++)
             {
                 FdoPtr<FdoExpression> arg = funcArgs->GetItem(i);
@@ -3495,7 +3495,7 @@
     case FdoExpressionItemType_UnaryExpression:
         {
             FdoUnaryExpression* unexpr = static_cast<FdoUnaryExpression*>(expr);
-            FdoExpression* inner = unexpr->GetExpression();
+            FdoPtr<FdoExpression> inner = unexpr->GetExpression();
 
             FdoPtr<FdoIdentifierCollection> result = ExtractIdentifiers(inner);
             for (FdoInt32 i = 0; i < result->GetCount(); i++)

Modified: branches/4.0/MgDev/Portable/MgPortable/Services/Feature/GwsConnectionPool.cpp
===================================================================
--- branches/4.0/MgDev/Portable/MgPortable/Services/Feature/GwsConnectionPool.cpp	2026-11-03 13:53:48 UTC (rev 10262)
+++ branches/4.0/MgDev/Portable/MgPortable/Services/Feature/GwsConnectionPool.cpp	2026-11-03 14:32:34 UTC (rev 10263)
@@ -40,6 +40,10 @@
             MgPortableFeatureConnection * conn = (*iter).second;
             if(conn)
             {
+                // The pool took these connections over from the reader, which owns them
+                // (OwnReader()), so Close() is what returns the FDO connection to the pool.
+                // It is a no-op for a connection a reader Close() already returned.
+                conn->Close();
                 conn->Release ();
             }
         }

Modified: branches/4.0/MgDev/Portable/MgPortable/Services/Feature/JoinFeatureReader.cpp
===================================================================
--- branches/4.0/MgDev/Portable/MgPortable/Services/Feature/JoinFeatureReader.cpp	2026-11-03 13:53:48 UTC (rev 10262)
+++ branches/4.0/MgDev/Portable/MgPortable/Services/Feature/JoinFeatureReader.cpp	2026-11-03 14:32:34 UTC (rev 10263)
@@ -19,7 +19,7 @@
 
 MgPortableJoinFeatureReader::MgPortableJoinFeatureReader(MgPortableGwsFeatureReader* reader)
 {
-    m_reader = SAFE_ADDREF(reader);
+    m_reader = reader;
 
     m_propertyNamesInitialized = false;
 }

Modified: branches/4.0/MgDev/Portable/MgPortable/Services/Feature/JoinFeatureReader.h
===================================================================
--- branches/4.0/MgDev/Portable/MgPortable/Services/Feature/JoinFeatureReader.h	2026-11-03 13:53:48 UTC (rev 10262)
+++ branches/4.0/MgDev/Portable/MgPortable/Services/Feature/JoinFeatureReader.h	2026-11-03 14:32:34 UTC (rev 10263)
@@ -562,7 +562,10 @@
     FdoObjectType MgObjectPropertyTypeToFdoObjectType(INT32 type);
     FdoOrderType MgOrderingOptionToFdoOrderType(INT32 type);
 
-    Ptr<MgPortableGwsFeatureReader> m_reader;
+    // Weak reference: the reader owns this object and holds it through
+    // MgPortableGwsFeatureReader::m_joinReader, so a counted reference here
+    // would make the pair a cycle that nothing can ever release.
+    MgPortableGwsFeatureReader* m_reader;
 
     // Used for access by index readers
     FdoStringsP m_propertyNames;

Modified: branches/4.0/MgDev/Portable/MgPortable/Services/ScrollableFeatureReader.cpp
===================================================================
--- branches/4.0/MgDev/Portable/MgPortable/Services/ScrollableFeatureReader.cpp	2026-11-03 13:53:48 UTC (rev 10262)
+++ branches/4.0/MgDev/Portable/MgPortable/Services/ScrollableFeatureReader.cpp	2026-11-03 14:32:34 UTC (rev 10263)
@@ -29,8 +29,9 @@
     m_scrollReader = FDO_SAFE_ADDREF(reader);
     m_connection = SAFE_ADDREF(conn);
 
-    // The reader takes ownership of the FDO connection
-    m_connection->OwnReader();
+    // The MgPortableFeatureReader constructor has already taken ownership of the FDO
+    // connection via OwnReader(). Calling OwnReader() again takes a second reference on
+    // it, which nothing releases, so the connection (and its schema cache) survives.
 }
 
 MgPortableScrollableFeatureReader::~MgPortableScrollableFeatureReader() 



More information about the mapguide-commits mailing list