AddressSanitizer: memory leak when changing the colum mode (data type)
Requirements
-
I searched through the issues if the issue already exists
Steps to reproduce
- Create a new project with a new spreadsheet
- change the column mode for a column for example from double to integer
Expected
No memory leaks.
Observed
Address Sanitizer is reporting multiple memory leaks related to the column filters. The call stack for creating objects that are not properly deleted:
Indirect leak of 80 byte(s) in 1 object(s) allocated from:
#0 0x7f11d49a7f78 in operator new(unsigned long) (/usr/lib64/libasan.so.8+0xd9f78) (BuildId: 61fead64e5783cda1359a1c30da2e9bab14d1e46)
#1 0x1538dc0 in AbstractAspect::AbstractAspect(QString const&, AspectType) /home/alex/Projekte/labplot/src/backend/core/AbstractAspect.cpp:189
#2 0x156f9df in AbstractFilter::AbstractFilter(QString const&) /home/alex/Projekte/labplot/src/backend/core/AbstractFilter.h:24
#3 0x156f9df in AbstractSimpleFilter::AbstractSimpleFilter() /home/alex/Projekte/labplot/src/backend/core/AbstractSimpleFilter.cpp:115
#4 0x15c91a8 in Double2StringFilter::Double2StringFilter(char, int) /home/alex/Projekte/labplot/src/backend/core/datatypes/Double2StringFilter.h:26
#5 0x15c91a8 in ColumnPrivate::initIOFilters() /home/alex/Projekte/labplot/src/backend/core/column/ColumnPrivate.cpp:837
#6 0x160ae35 in ColumnPrivate::ColumnPrivate(Column*, AbstractColumn::ColumnMode) /home/alex/Projekte/labplot/src/backend/core/column/ColumnPrivate.cpp:757
#7 0x15a05d5 in Column::Column(QString const&, AbstractColumn::ColumnMode) /home/alex/Projekte/labplot/src/backend/core/column/Column.cpp:61
#8 0x1b1418a in Spreadsheet::init() /home/alex/Projekte/labplot/src/backend/spreadsheet/Spreadsheet.cpp:84
#9 0x1b146b7 in Spreadsheet::Spreadsheet(QString const&, bool, AspectType) /home/alex/Projekte/labplot/src/backend/spreadsheet/Spreadsheet.cpp:65
#10 0x6b79c8 in MainWin::newSpreadsheet() /home/alex/Projekte/labplot/src/kdefrontend/MainWin.cpp:2074
#11 0x6e6fa2 in MainWin::newProject(bool) /home/alex/Projekte/labplot/src/kdefrontend/MainWin.cpp:1511
#12 0x6f2592 in MainWin::initGUI(QString const&) /home/alex/Projekte/labplot/src/kdefrontend/MainWin.cpp:388
#13 0x6f5407 in MainWin::MainWin(QWidget*, QString const&) /home/alex/Projekte/labplot/src/kdefrontend/MainWin.cpp:164
#14 0x6118c3 in main /home/alex/Projekte/labplot/src/kdefrontend/LabPlot.cpp:229
#15 0x7f11cf45e24c in __libc_start_main (/lib64/libc.so.6+0x3524c) (BuildId: f732026552f6adff988b338e92d466bc81a01c37)
Apparently, the initially created column filters in the new spreadsheet are not properly deleted after the column mode change.
LabPlot Version
Debug build 2.10.0-2156-g44fa1d3eb
Mar 15 2024, 09:02:48
System: openSUSE Leap 15.5
Locale: English,United States (Decimal point '.', Group separator ','
Number settings: Decimal point '.', Group separator ',', Exponential 'e', Zero digit '0', Percent '%', Positive/Negative sign '+'/'-' (Updated on restart)
Architecture: x86_64-little_endian-lp64
Kernel: linux 5.14.21-150500.55.49-default
C++ Compiler: GNU 12.3.0
C++ Compiler Flags: -fno-operator-names -fno-exceptions -Wall -Wextra -Wcast-align -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type -Werror=init-self -Wvla -Wdate-time -Wsuggest-override -Wlogical-op -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -Wall -Wextra -Wundef -Wpointer-arith -Wunreachable-code -Wunused -Wdeprecated-declarations -fno-omit-frame-pointer -fstack-protector -fexceptions -std=c++17 -O2 -Wcast-align -Wswitch-enum -fvisibility=default -pedantic -Wzero-as-null-pointer-constant
Edited by Alexander Semke