Xerces-C++
  1. Xerces-C++
  2. XERCESC-1348

IGXMLScanner allocates from wrong memory manager

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.6.0
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      Found on solaris, but no a solaris issue.

      Description

      IGXMLScanner.c allocates from fGrammarPoolMemoryManager instead of fMemoryManager.

      This causes a memory leak and thread safety issues when sharing
      an unsynchronized grammar pool across multiple threads. I included diffs
      that affect my application but I suspect this problem exists for other
      scanners too. It would be good if somebody could check all uses of
      fGrammarPoolMemoryManager to verify the immutability of cached grammars
      and thread safety for the GrammarPool. When not parsing grammars, the
      pool should not change.

      > diff IGXMLScanner.cpp IGXMLScanner.cpp.orig
      1256,1257c1256
      < MemoryManager rootDeclMgr = /*MDW/fUseCachedGrammar ? fMemoryManager : fGrammarPoolMemoryManager;
      < DTDElementDecl* rootDecl = new (/MDW/rootDeclMgr) DTDElementDecl

      > DTDElementDecl* rootDecl = new (fGrammarPoolMemoryManager) DTDElementDecl
      1262c1261
      < , /MDW/rootDeclMgr

      > , fGrammarPoolMemoryManager
      1497c1496
      < DTDEntityDecl* declDTD = new (fMemoryManager/MDW/) DTDEntityDecl(gDTDStr, false, fMemoryManager/MDW/);

      > DTDEntityDecl* declDTD = new (fGrammarPoolMemoryManager) DTDEntityDecl(gDTDStr, false, fGrammarPoolMemoryManager);

      1. patch.txt
        7 kB
        David Bertoni

        Activity

        Hide
        David Bertoni added a comment -

        Mark, if you're still there, can you review this patch? Thanks!

        Show
        David Bertoni added a comment - Mark, if you're still there, can you review this patch? Thanks!
        Hide
        Christian Will added a comment -

        Hi Dave,

        your patch is for xalan and not for xerces.

        Show
        Christian Will added a comment - Hi Dave, your patch is for xalan and not for xerces.
        Hide
        David Bertoni added a comment -

        OK, I hope I got the patch right this time!

        Show
        David Bertoni added a comment - OK, I hope I got the patch right this time!
        Hide
        David Bertoni added a comment -

        OK, here's another patch that removes some dead code and fixes similar issues in DGXMLScanner.cpp

        Show
        David Bertoni added a comment - OK, here's another patch that removes some dead code and fixes similar issues in DGXMLScanner.cpp
        Hide
        cargilld added a comment -

        Hi Dave,
        I reviewed the patch and it looks good. Please commit.

        David

        Show
        cargilld added a comment - Hi Dave, I reviewed the patch and it looks good. Please commit. David
        Hide
        David Bertoni added a comment -

        Fix is in Subversion.

        Show
        David Bertoni added a comment - Fix is in Subversion.
        Hide
        Alberto Massari added a comment -

        The bug is still listed as "unresolved"; trying to change its status to "resolved"...

        Show
        Alberto Massari added a comment - The bug is still listed as "unresolved"; trying to change its status to "resolved"...

          People

          • Assignee:
            David Bertoni
            Reporter:
            Mark Weissman
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development