Skip to content

libsbml.writeMathMLWithNamespaceToString leaks memory #438

@dweindl

Description

@dweindl

It looks like libsbml.writeMathMLWithNamespaceToString leaks memory:

$ valgrind --leak-check=full python -c "import libsbml; libsbml.writeMathMLWithNamespaceToString(libsbml.ASTNode(), libsbml.SBMLNamespaces(3, 2))"
# output
==320841== Memcheck, a memory error detector
==320841== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==320841== Using Valgrind-3.24.0 and LibVEX; rerun with -h for copyright info
==320841== Command: python -c import\ libsbml;\ libsbml.writeMathMLWithNamespaceToString(libsbml.ASTNode(),\ libsbml.SBMLNamespaces(3,\ 2))
==320841== 
==320841== 
==320841== HEAP SUMMARY:
==320841==     in use at exit: 483,812 bytes in 20 blocks
==320841==   total heap usage: 65,487 allocs, 65,467 frees, 151,614,594 bytes allocated
==320841== 
==320841== 90 bytes in 1 blocks are definitely lost in loss record 5 of 15
==320841==    at 0x484A858: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==320841==    by 0x9D4621F: safe_strdup (in lib/python3.13/site-packages/libsbml/_libsbml.cpython-313-x86_64-linux-gnu.so)
==320841==    by 0x9D3BF12: writeMathMLWithNamespaceToString (in lib/python3.13/site-packages/libsbml/_libsbml.cpython-313-x86_64-linux-gnu.so)
==320841==    by 0x95DB9CC: _wrap_writeMathMLWithNamespaceToString (in lib/python3.13/site-packages/libsbml/_libsbml.cpython-313-x86_64-linux-gnu.so)
==320841==    by 0x58D527: ??? (in /usr/bin/python3.13)
==320841==    by 0x54AB72: _PyObject_MakeTpCall (in /usr/bin/python3.13)
==320841==    by 0x567183: _PyEval_EvalFrameDefault (in /usr/bin/python3.13)
==320841==    by 0x65B4DC: PyEval_EvalCode (in /usr/bin/python3.13)
==320841==    by 0x67C201: ??? (in /usr/bin/python3.13)
==320841==    by 0x67810D: ??? (in /usr/bin/python3.13)
==320841==    by 0x66A1C5: ??? (in /usr/bin/python3.13)
==320841==    by 0x66A0D0: ??? (in /usr/bin/python3.13)
==320841== 
==320841== LEAK SUMMARY:
==320841==    definitely lost: 90 bytes in 1 blocks
==320841==    indirectly lost: 0 bytes in 0 blocks
==320841==      possibly lost: 0 bytes in 0 blocks
==320841==    still reachable: 483,690 bytes in 18 blocks
==320841==         suppressed: 32 bytes in 1 blocks
==320841== Reachable blocks (those to which a pointer was found) are not shown.
==320841== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==320841== 
==320841== For lists of detected and suppressed errors, rerun with: -s
==320841== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

python-libsbml==5.20.5 with Python 3.13.3 on Ubuntu 25.04.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions