Qalculate / libqalculate

Qalculate! library and CLI
https://qalculate.github.io/
GNU General Public License v2.0
1.85k stars 148 forks source link

Crash in Calculator destructor #468

Closed dschopf closed 1 year ago

dschopf commented 2 years ago

When running this code on the latest Arch Linux package libqalculate 4.3.0-1 there is a crash.

#include <memory>

#include <libqalculate/qalculate.h>

int main()
{
  auto calc{std::make_unique<Calculator>()};
  calc->loadGlobalDefinitions();
}

Backtrace from GDB shows this:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00007ffff7b6844f in Calculator::~Calculator (this=<optimized out>, this=<optimized out>)
    at /build/libqalculate/src/libqalculate-4.3.0/libqalculate/Calculator.cc:606
#2  0x00007ffff7b6921e in Calculator::~Calculator (this=<optimized out>, this=<optimized out>)
    at /build/libqalculate/src/libqalculate-4.3.0/libqalculate/Calculator.cc:619
#3  0x00005555555557bc in std::default_delete<Calculator>::operator() (this=0x7fffffffdcd0, __ptr=0x55555556c190)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/bits/unique_ptr.h:95
#4  0x000055555555555d in std::unique_ptr<Calculator, std::default_delete<Calculator> >::~unique_ptr (this=0x7fffffffdcd0)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/bits/unique_ptr.h:396
#5  0x00005555555553d1 in main () at qalculate.cpp:9
(gdb) 

Is there anything wrong in the way I use the Calulator class or is this a real issue maybe introduced when fixing #444?

hanna-kn commented 2 years ago

Fixed.