Bug 454006

Summary: Certain math equations crash krunner
Product: [Plasma] krunner Reporter: Sam <thenerdiestguy>
Component: calculatorAssignee: Alexander Lohnau <alexander.lohnau>
Status: RESOLVED UPSTREAM    
Severity: crash CC: arojas, kde, nate, plasma-bugs, thenerdiestguy
Priority: NOR    
Version: 5.24.5   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
URL: https://github.com/Qalculate/libqalculate/issues/438
Latest Commit: Version Fixed In:

Description Sam 2022-05-18 17:50:25 UTC
SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE
1. Run krunner
2. Type in any of these:
25**(-1/5)
pi**pi=
3. Observe

OBSERVED RESULT
Krunner closes

EXPECTED RESULT
Krunner should compute them

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 2.24.5
KDE Frameworks Version: 5.94.0
Qt Version: 5.15.4

ADDITIONAL INFORMATION
Backtrace:
>> 25**(-1/5)
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007ffff5b3f3d3 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007ffff5aef838 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff5ad9535 in __GI_abort () at abort.c:79
#4  0x00007ffff5b3345e in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff5c7183e "%s\n") at ../sysdeps/posix/libc_fatal.c:155
#5  0x00007ffff5b490cc in malloc_printerr (str=str@entry=0x7ffff5c6f336 "free(): invalid pointer") at malloc.c:5664
#6  0x00007ffff5b4af6c in _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:4439
#7  0x00007ffff5b4d8f3 in __GI___libc_free (mem=<optimized out>) at malloc.c:3391
#8  0x00007fff91fdb74d in mpfr_free_func () at /usr/lib/libmpfr.so.6
#9  0x00007fff91fd67d2 in mpfr_clear () at /usr/lib/libmpfr.so.6
#10 0x00007fff9200b1b8 in mpfr_get_z () at /usr/lib/libmpfr.so.6
#11 0x00007fff91ff074c in mpfr_pow () at /usr/lib/libmpfr.so.6
#12 0x00007fff9234ef6f in Number::print[abi:cxx11](PrintOptions const&, InternalPrintStruct const&) const () at /usr/lib/libqalculate.so.22
#13 0x00007fff924ebc32 in MathStructure::print[abi:cxx11](PrintOptions const&, bool, int, int, InternalPrintStruct const&) const ()
    at /usr/lib/libqalculate.so.22
#14 0x00007fff924e836c in MathStructure::print[abi:cxx11](PrintOptions const&, InternalPrintStruct const&) const () at /usr/lib/libqalculate.so.22
#15 0x00007fffa817aad8 in QalculateEngine::evaluate(QString const&, bool*) (this=0x555556a625b0, isApproximate=0x7fff9102993f, expression=<optimized out>)
    at /usr/src/debug/plasma-workspace-5.24.5/runners/calculator/qalculate_engine.cpp:110
#16 0x00007fffa817b8c8 in CalculatorRunner::calculate(QString const&, bool*) (isApproximate=0x7fff9102993f, term=..., this=0x555556a2a190)
    at /usr/src/debug/plasma-workspace-5.24.5/runners/calculator/calculatorrunner.cpp:143
#17 CalculatorRunner::match(Plasma::RunnerContext&) (this=0x555556a2a190, context=...)
    at /usr/src/debug/plasma-workspace-5.24.5/runners/calculator/calculatorrunner.cpp:118
#18 0x00007ffff7e196c0 in Plasma::FindMatchesJob::run(QSharedPointer<ThreadWeaver::JobInterface>, ThreadWeaver::Thread*) (this=0x555555b59100, self=...)
    at /usr/src/debug/krunner-5.94.0/src/runnerjobs.cpp:140
#19 0x00007ffff585811e in ThreadWeaver::Executor::run(QSharedPointer<ThreadWeaver::JobInterface> const&, ThreadWeaver::Thread*)
    (this=<optimized out>, job=<optimized out>, thread=<optimized out>) at /usr/src/debug/threadweaver-5.94.0/src/executor.cpp:33
#20 0x00007ffff5859066 in ThreadWeaver::Job::execute(QSharedPointer<ThreadWeaver::JobInterface> const&, ThreadWeaver::Thread*)
    (this=<optimized out>, self=..., th=0x555556d86880) at /usr/src/debug/threadweaver-5.94.0/src/job.cpp:64
#21 0x00007ffff585cd92 in ThreadWeaver::Thread::run() (this=0x555556d86880) at /usr/src/debug/threadweaver-5.94.0/src/thread.cpp:98
#22 0x00007ffff5fd935a in QThreadPrivate::start(void*) (arg=0x555556d86880) at thread/qthread_unix.cpp:331
#23 0x00007ffff5b3d54d in start_thread (arg=<optimized out>) at pthread_create.c:442
#24 0x00007ffff5bc2b14 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:100

>> pi**pi=
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007ffff5b3f3d3 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007ffff5aef838 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff5ad9535 in __GI_abort () at abort.c:79
#4  0x00007ffff5b3345e in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff5c7183e "%s\n") at ../sysdeps/posix/libc_fatal.c:155
#5  0x00007ffff5b490cc in malloc_printerr (str=str@entry=0x7ffff5c73eb0 "munmap_chunk(): invalid pointer") at malloc.c:5664
#6  0x00007ffff5b493bc in munmap_chunk (p=<optimized out>) at malloc.c:3060
#7  0x00007ffff5b4d93a in __GI___libc_free (mem=<optimized out>) at malloc.c:3381
#8  0x00007ffff0f57504 in __gmpz_mul () at /usr/lib/libgmp.so.10
#9  0x00007fff91ffb6b3 in mpfr_exp_2 () at /usr/lib/libmpfr.so.6
#10 0x00007fff91fe5025 in mpfr_exp () at /usr/lib/libmpfr.so.6
#11 0x00007fff91fef782 in mpfr_pow_general () at /usr/lib/libmpfr.so.6
#12 0x00007fff91ff008e in mpfr_pow () at /usr/lib/libmpfr.so.6
#13 0x00007fff9231a53c in Number::raise(Number const&, bool) () at /usr/lib/libqalculate.so.22
#14 0x00007fff92522c38 in MathStructure::merge_power(MathStructure&, EvaluationOptions const&, MathStructure*, unsigned long, unsigned long, bool) ()
    at /usr/lib/libqalculate.so.22
#15 0x00007fff92533c05 in MathStructure::calculatesub(EvaluationOptions const&, EvaluationOptions const&, bool, MathStructure*, unsigned long) ()
    at /usr/lib/libqalculate.so.22
#16 0x00007fff9256501f in MathStructure::eval(EvaluationOptions const&) () at /usr/lib/libqalculate.so.22
#17 0x00007fff922dde01 in Calculator::calculate(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, EvaluationOptions const&, MathStructure*, MathStructure*, bool) () at /usr/lib/libqalculate.so.22
#18 0x00007fffa817aa46 in QalculateEngine::evaluate(QString const&, bool*) (this=0x555556a5e1e0, isApproximate=0x7fff837fd93f, expression=<optimized out>)
    at /usr/src/debug/plasma-workspace-5.24.5/runners/calculator/qalculate_engine.cpp:93
#19 0x00007fffa817b8c8 in CalculatorRunner::calculate(QString const&, bool*) (isApproximate=0x7fff837fd93f, term=..., this=0x555556a2b7e0)
    at /usr/src/debug/plasma-workspace-5.24.5/runners/calculator/calculatorrunner.cpp:143
#20 CalculatorRunner::match(Plasma::RunnerContext&) (this=0x555556a2b7e0, context=...)
    at /usr/src/debug/plasma-workspace-5.24.5/runners/calculator/calculatorrunner.cpp:118
#21 0x00007ffff7e196c0 in Plasma::FindMatchesJob::run(QSharedPointer<ThreadWeaver::JobInterface>, ThreadWeaver::Thread*) (this=0x555556dfaf80, self=...)
    at /usr/src/debug/krunner-5.94.0/src/runnerjobs.cpp:140
#22 0x00007ffff585811e in ThreadWeaver::Executor::run(QSharedPointer<ThreadWeaver::JobInterface> const&, ThreadWeaver::Thread*)
    (this=<optimized out>, job=<optimized out>, thread=<optimized out>) at /usr/src/debug/threadweaver-5.94.0/src/executor.cpp:33
#23 0x00007ffff5859066 in ThreadWeaver::Job::execute(QSharedPointer<ThreadWeaver::JobInterface> const&, ThreadWeaver::Thread*)
    (this=<optimized out>, self=..., th=0x555556f5ea30) at /usr/src/debug/threadweaver-5.94.0/src/job.cpp:64
#24 0x00007ffff585cd92 in ThreadWeaver::Thread::run() (this=0x555556f5ea30) at /usr/src/debug/threadweaver-5.94.0/src/thread.cpp:98
#25 0x00007ffff5fd935a in QThreadPrivate::start(void*) (arg=0x555556f5ea30) at thread/qthread_unix.cpp:331
#26 0x00007ffff5b3d54d in start_thread (arg=<optimized out>) at pthread_create.c:442
#27 0x00007ffff5bc2b14 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:100
Comment 1 Alexander Lohnau 2022-05-19 06:01:07 UTC
It does not crash for me with the calculations you provided. What is your Qalculate version?
Comment 2 Sam 2022-05-19 06:01:58 UTC
libqalculate 4.1.1-2
Comment 3 Alexander Lohnau 2022-05-19 06:12:18 UTC
I have 2.8.2. Do you get the same crash when using the qalc CLI program?
Comment 4 Sam 2022-05-19 06:13:42 UTC
> pi**pi=

  pi^pi ≈ 36.46215961

> 25**(-1/5)

  25^((−1) / 5) ≈ 0.5253055609

So I'll take that as a no
Comment 5 Alexander Lohnau 2022-05-19 16:30:41 UTC
Thanks for the additional info. I will need to compile qalculate from source, rebuild plasma-workspace and see if I can reproduce the issue. I am currently on vacation so I might need a bit of time :)
Comment 6 Alexander Lohnau 2022-05-20 11:29:45 UTC
It works as expected with qalculate master and the version number you provided. I have build it from source and made sure the calculator runner was recompiled.
Comment 7 Sam 2022-05-20 13:18:41 UTC
Well, I'm not sure how much more I could help in debugging it...
Comment 8 Antonio Rojas 2022-05-25 09:42:46 UTC
*** Bug 454383 has been marked as a duplicate of this bug. ***
Comment 9 Antonio Rojas 2022-05-25 09:48:11 UTC
https://github.com/Qalculate/libqalculate/issues/438