Skip to content

Initialize fRefCnt in rapidxml XML file implementations#174

Open
key2 wants to merge 1 commit into
mvrdevelopment:masterfrom
key2:fix-rapidxml-refcnt
Open

Initialize fRefCnt in rapidxml XML file implementations#174
key2 wants to merge 1 commit into
mvrdevelopment:masterfrom
key2:fix-rapidxml-refcnt

Conversation

@key2

@key2 key2 commented Jul 22, 2026

Copy link
Copy Markdown

Problem

CXMLFileImpl and CXMLFileNodeImpl (rapidxmlsupport, used with DONT_USE_XERCES_AS_XMLLIB) implement IVWUnknown reference counting manually, but their constructors never initialize fRefCnt. The member starts with whatever the allocator returns.

Effects

  • On typical glibc heaps the garbage value is non-zero, so the count never reaches 0 in Release() and every XML file/node object is leaked silently.
  • On allocators that hand out zeroed pages (e.g. a fresh WebAssembly/Emscripten heap, where we found this while porting the library), Release() is entered with fRefCnt == 0 and prints the fRefCnt > 0 assert for every single node while parsing — thousands of lines per GDTF/MVR file.

Fix

Initialize fRefCnt = 0 in both constructors, matching what VCOMImpl<T> does for all other implementations.

Verified by parsing all files from gdtf-share samples with the rapidxml backend: no assert output, objects are correctly destroyed.

CXMLFileImpl and CXMLFileNodeImpl implement IVWUnknown reference
counting manually but never initialized fRefCnt in their constructors.
With typical glibc heap contents the garbage value is non-zero, so the
objects are never destroyed (silent leak); on allocators that return
zeroed pages (e.g. a fresh WebAssembly heap) Release() is entered with
fRefCnt == 0 and triggers the 'fRefCnt > 0' assert for every node.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant