Skip to content

Comments

Fix Valgrind memory errors#1246

Closed
leekillough wants to merge 2 commits intosstsimulator:develfrom
leekillough:fix_memory_errors
Closed

Fix Valgrind memory errors#1246
leekillough wants to merge 2 commits intosstsimulator:develfrom
leekillough:fix_memory_errors

Conversation

@leekillough
Copy link
Contributor

This fixes some Valgrind errors, namely uninitialized data and memory leaks, but there are still "definite" leaks, some of which are caused by classes containing pointers being destroyed without deleting the pointers, even if it does not occur until program exit.

Some of the fixed errors are listed below.

==388622== Syscall param writev(vector[1]) points to uninitialised byte(s)
==388622==    at 0x576C06D: __writev (writev.c:26)
==388622==    by 0x576C06D: writev (writev.c:24)
==388622==    by 0x54A2C71: std::__basic_file<char>::xsputn_2(char const*, long, char const*, long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.32)
==388622==    by 0x54E732B: std::basic_filebuf<char, std::char_traits<char> >::xsputn(char const*, long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.32)
==388622==    by 0x55109A5: std::ostream::write(char const*, long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.32)
==388622==    by 0x45C466: SST::Simulation_impl::checkpoint(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (simulation.cc:1723)
==388622==    by 0x334B90: SST::CheckpointAction::createCheckpoint(SST::Simulation_impl*) (checkpointAction.cc:123)
==388622==    by 0x33530C: SST::CheckpointAction::execute() (checkpointAction.cc:72)
==388622==    by 0x457E57: SST::Simulation_impl::run() (simulation.cc:871)
==388622==    by 0x2D3D7D: start_simulation(unsigned int, SimThreadInfo_t&, SST::Core::ThreadSafe::Barrier&) (main.cc:596)
==388622==    by 0x2B1377: main (main.cc:1104)
==388622==  Address 0x97b17b2 is 98 bytes inside a block of size 16,912 alloc'd
==388622==    at 0x4859047: operator new(unsigned long) (vg_replace_malloc.c:472)
==388622==    by 0x2EC15C: allocate (new_allocator.h:137)
==388622==    by 0x2EC15C: allocate (alloc_traits.h:464)
==388622==    by 0x2EC15C: _M_allocate (stl_vector.h:378)
==388622==    by 0x2EC15C: std::__cxx1998::vector<char, std::allocator<char> >::_M_default_append(unsigned long) (vector.tcc:657)
==388622==    by 0x45C612: resize (stl_vector.h:1011)
==388622==    by 0x45C612: resize (vector:370)
==388622==    by 0x45C612: SST::Simulation_impl::checkpoint(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (simulation.cc:1716)
==388622==    by 0x334B90: SST::CheckpointAction::createCheckpoint(SST::Simulation_impl*) (checkpointAction.cc:123)
==388622==    by 0x33530C: SST::CheckpointAction::execute() (checkpointAction.cc:72)
==388622==    by 0x457E57: SST::Simulation_impl::run() (simulation.cc:871)
==388622==    by 0x2D3D7D: start_simulation(unsigned int, SimThreadInfo_t&, SST::Core::ThreadSafe::Barrier&) (main.cc:596)
==388622==    by 0x2B1377: main (main.cc:1104)
==388622==  Uninitialised value was created by a heap allocation
==388622==    at 0x4859047: operator new(unsigned long) (vg_replace_malloc.c:472)
==388622==    by 0x373873: SST::ConfigGraph::addComponent(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (configGraph.cc:784)
==388622==    by 0x59600E: addComponent (pymodel.h:94)
==388622==    by 0x59600E: compInit(ComponentPy_t*, _object*, _object*) (pymodel_comp.cc:95)
==388622==    by 0x4A7E431: ??? (in /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0)
==388622==    by 0x4A186C0: _PyObject_MakeTpCall (in /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0)
==388622==    by 0x49ABBB6: _PyEval_EvalFrameDefault (in /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0)
==388622==    by 0x4C6E13B: ??? (in /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0)
==388622==    by 0x4B069F4: PyEval_EvalCode (in /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0)
==388622==    by 0x4B55E28: ??? (in /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0)
==388622==    by 0x4B567E5: _PyRun_SimpleFileObject (in /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0)
==388622==    by 0x4B56DBF: _PyRun_AnyFileObject (in /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0)
==388622==    by 0x4B56E7C: PyRun_AnyFileExFlags (in /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0)
==388622==

==388622== 12 bytes in 4 blocks are definitely lost in loss record 391 of 2,169
==388622==    at 0x48588A1: malloc (vg_replace_malloc.c:431)
==388622==    by 0x570078D: strdup (strdup.c:42)
==388622==    by 0x595FDA: compInit(ComponentPy_t*, _object*, _object*) (pymodel_comp.cc:94)
==388622==    by 0x4A7E431: ??? (in /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0)
==388622==    by 0x4A186C0: _PyObject_MakeTpCall (in /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0)
==388622==    by 0x49ABBB6: _PyEval_EvalFrameDefault (in /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0)
==388622==    by 0x4C6E13B: ??? (in /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0)
==388622==    by 0x4B069F4: PyEval_EvalCode (in /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0)
==388622==    by 0x4B55E28: ??? (in /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0)
==388622==    by 0x4B567E5: _PyRun_SimpleFileObject (in /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0)
==388622==    by 0x4B56DBF: _PyRun_AnyFileObject (in /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0)
==388622==    by 0x4B56E7C: PyRun_AnyFileExFlags (in /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0)
==388622==

@github-actions github-actions bot added AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) AT: CLANG-FORMAT FAIL labels Mar 12, 2025
@github-actions
Copy link

CLANG-FORMAT TEST - FAILED (on last commit):
Run > ./scripts/clang-format-test.sh using clang-format v12 to check formatting

@github-actions github-actions bot added AT: CMAKE-FORMAT PASS and removed AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) labels Mar 12, 2025
@github-actions
Copy link

CMAKE-FORMAT TEST - PASSED

@sst-autotester
Copy link
Contributor

Status Flag 'Pre-Test Inspection' - - This Pull Request Requires Inspection... The code must be inspected by a member of the Team before Testing/Merging
NO INSPECTION HAS BEEN PERFORMED ON THIS PULL REQUEST! - This PR must be inspected by setting label 'AT: PRE-TEST INSPECTED'.

@feldergast feldergast added the AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) label Mar 18, 2025
@github-actions
Copy link

CLANG-FORMAT TEST - FAILED (on last commit):
Run > ./scripts/clang-format-test.sh using clang-format v12 to check formatting

@github-actions github-actions bot removed the AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) label Mar 23, 2025
@github-actions
Copy link

CMAKE-FORMAT TEST - PASSED

@sst-autotester
Copy link
Contributor

Status Flag 'Pre-Test Inspection' - - This Pull Request Requires Inspection... The code must be inspected by a member of the Team before Testing/Merging
NO INSPECTION HAS BEEN PERFORMED ON THIS PULL REQUEST! - This PR must be inspected by setting label 'AT: PRE-TEST INSPECTED'.

@feldergast feldergast added the AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) label Mar 23, 2025
@leekillough leekillough deleted the fix_memory_errors branch March 31, 2025 04:10
@berquist berquist added this to the SST V15.0.0 milestone Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AT: CLANG-FORMAT FAIL AT: CMAKE-FORMAT PASS AT: WIP Mark PR as a Work in Progress (No Autotesting Performed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants