Bug 494799 - kcalc unresponsive after invalid input
Summary: kcalc unresponsive after invalid input
Status: RESOLVED FIXED
Alias: None
Product: kcalc
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Gabriel Barrantes
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-10-15 08:25 UTC by sebott
Modified: 2024-10-19 16:44 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sebott 2024-10-15 08:25:26 UTC
SUMMARY
Using kcalc in the Numeral System Mode / Hex view and adding invalid characters into the input field leads to an unresponsive app.
STEPS TO REPRODUCE
1. kcalc Numeral System Mode
2. enter invalid input like "id_aa64pfr0"
3. trying to delete that input

OBSERVED RESULT
kcalc becomes unresponsive

EXPECTED RESULT
not become unresponsive, display nan or smth

SOFTWARE/OS VERSIONS
Operating System: Fedora Linux 40
KDE Plasma Version: 6.2.0
KDE Frameworks Version: 6.7.0
Qt Version: 6.7.2

ADDITIONAL INFORMATION
playing around with inputs, looks like "i" is enough to trigger this maybe that gets evaluated as a symbol

unhelpful stack:
#0  CalcEngine::insert_KNumber_Token_In_Stack_(KCalcToken const&) [clone .isra.0] (this=this@entry=0x5555557ae5d8, token=<optimized out>)
    at /usr/src/debug/kcalc-24.08.2-1.fc40.x86_64/kcalc_core.cpp:352
#1  0x000055555559f9f9 in CalcEngine::calculate (this=0x5555557ae5d8, tokenBuffer=..., errorIndex=@0x5555557ae4a0: 0)
    at /usr/src/debug/kcalc-24.08.2-1.fc40.x86_64/kcalc_core.cpp:134
#2  0x00005555555c4384 in KCalculator::commit_Input_() [clone .isra.0] (this=0x5555557ae0f0)
    at /usr/src/debug/kcalc-24.08.2-1.fc40.x86_64/kcalc.cpp:2391
#3  0x000055555558e2e6 in KCalculator::slotInputChanged (this=0x5555557ae0f0) at /usr/src/debug/kcalc-24.08.2-1.fc40.x86_64/kcalc.cpp:1414
#4  0x00007ffff5ffc8f2 in void doActivate<false>(QObject*, int, void**) () at /lib64/libQt6Core.so.6
#5  0x00007ffff752c9d9 in QLineEdit::textChanged(QString const&) () at /lib64/libQt6Widgets.so.6
#6  0x00007ffff5ffc8f2 in void doActivate<false>(QObject*, int, void**) () at /lib64/libQt6Core.so.6
#7  0x00007ffff7538bec in QWidgetLineControl::textChanged(QString const&) () at /lib64/libQt6Widgets.so.6
#8  0x00007ffff753be7f in QWidgetLineControl::finishChange(int, bool, bool) () at /lib64/libQt6Widgets.so.6
#9  0x00007ffff753f26a in QWidgetLineControl::processKeyEvent(QKeyEvent*) () at /lib64/libQt6Widgets.so.6
#10 0x00007ffff752c94f in QLineEdit::keyPressEvent(QKeyEvent*) () at /lib64/libQt6Widgets.so.6
Comment 1 Gabriel Barrantes 2024-10-15 20:32:54 UTC
can't reproduce, did you get the "Syntax error" message? What version is the issue happening?
Comment 2 Muelsyse 2024-10-16 02:47:49 UTC
I can reproduce this with the KCalc 24.08.2 Flatpak on Fedora 41 Beta.
It doesn't have to be in Numerical System Mode, it occurs in Simple mode as well. All you have to do is type the letter 'i' and it will cause the program to become unresponsive and in need of termination. Termination produces a core dump but it doesn't seem to be helpful.

STEPS TO REPRODUCE:
Scenario 1: Open the KCalc program (in Simple mode), type 'i', watch as it becomes unresponsive.

SOFTWARE/OS VERSIONS:
Operating System: Fedora Kinoite 41 Beta
KDE Plasma Version: 6.2.0
KDE Frameworks Version: 6.7.0
Qt Version: 6.7.2

ADDITIONAL INFORMATION:
While journalctl doesn't give much info, there are a few entries of potential interest

Oct 16 10:36:01 fedora systemd[1657]: Started app-org.kde.kcalc@9ba059c4b549431fb8e9bdec41fedfa7.service - KCalc - Scientific Calculator.
Oct 16 10:36:01 fedora systemd[1657]: Started app-flatpak-org.kde.kcalc-6333.scope.
Oct 16 10:36:01 fedora flatpak[6345]: Detected locale "C" with character encoding "ANSI_X3.4-1968", which is not UTF-8.
Oct 16 10:36:01 fedora flatpak[6345]: Qt depends on a UTF-8 locale, and has switched to "C.UTF-8" instead.
Oct 16 10:36:01 fedora flatpak[6345]: If this causes problems, reconfigure your locale. See the locale(1) manual
Oct 16 10:36:01 fedora flatpak[6345]: for more information.

Here is the core dump given after termination

           PID: 6345 (kcalc)
           UID: 1000 (fatomic)
           GID: 1000 (fatomic)
        Signal: 6 (ABRT)
     Timestamp: Wed 2024-10-16 10:36:33 +08 (9min ago)
  Command Line: kcalc
    Executable: /app/bin/kcalc
 Control Group: /user.slice/user-1000.slice/user@1000.service/app.slice/app-flatpak-org.kde.kcalc-6333.scope
          Unit: user@1000.service
     User Unit: app-flatpak-org.kde.kcalc-6333.scope
         Slice: user-1000.slice
     Owner UID: 1000 (fatomic)
       Boot ID: 069687c9f5c143d7b25d4f538df6a360
    Machine ID: 2140b13e81ae4fe28398c24ac346e6c8
      Hostname: fedora
       Storage: /var/lib/systemd/coredump/core.kcalc.1000.069687c9f5c143d7b25d4f538df6a360.6345.1729046193000000.zst (present)
  Size on Disk: 2.7M
       Message: Process 6345 (kcalc) of user 1000 dumped core.
                
                Stack trace of thread 2:
                #0  0x000055cb6a589bc1 n/a (/app/bin/kcalc + 0x68bc1)
                #1  0x000055cb6a575e04 n/a (/app/bin/kcalc + 0x54e04)
                #2  0x000055cb6a55175c n/a (/app/bin/kcalc + 0x3075c)
                #3  0x000055cb6a55582c n/a (/app/bin/kcalc + 0x3482c)
                #4  0x00007f611efe55fe n/a (/usr/lib/x86_64-linux-gnu/libQt6Core.so.6.7.3 + 0x1e55fe)
                #5  0x00007f6120532c79 n/a (/usr/lib/x86_64-linux-gnu/libQt6Widgets.so.6.7.3 + 0x332c79)
                #6  0x00007f611efe55fe n/a (/usr/lib/x86_64-linux-gnu/libQt6Core.so.6.7.3 + 0x1e55fe)
                #7  0x00007f612053ed5c n/a (/usr/lib/x86_64-linux-gnu/libQt6Widgets.so.6.7.3 + 0x33ed5c)
                #8  0x00007f6120541f97 n/a (/usr/lib/x86_64-linux-gnu/libQt6Widgets.so.6.7.3 + 0x341f97)
                #9  0x00007f6120544f05 n/a (/usr/lib/x86_64-linux-gnu/libQt6Widgets.so.6.7.3 + 0x344f05)
                #10 0x00007f6120532bef n/a (/usr/lib/x86_64-linux-gnu/libQt6Widgets.so.6.7.3 + 0x332bef)
                #11 0x00007f61203fe608 n/a (/usr/lib/x86_64-linux-gnu/libQt6Widgets.so.6.7.3 + 0x1fe608)
                #12 0x00007f612039e3d8 n/a (/usr/lib/x86_64-linux-gnu/libQt6Widgets.so.6.7.3 + 0x19e3d8)
                #13 0x00007f61203a8204 n/a (/usr/lib/x86_64-linux-gnu/libQt6Widgets.so.6.7.3 + 0x1a8204)
                #14 0x00007f611ef82e40 n/a (/usr/lib/x86_64-linux-gnu/libQt6Core.so.6.7.3 + 0x182e40)
                #15 0x00007f6120413ac0 n/a (/usr/lib/x86_64-linux-gnu/libQt6Widgets.so.6.7.3 + 0x213ac0)
                #16 0x00007f612039e3d8 n/a (/usr/lib/x86_64-linux-gnu/libQt6Widgets.so.6.7.3 + 0x19e3d8)
                #17 0x00007f611ef82e40 n/a (/usr/lib/x86_64-linux-gnu/libQt6Core.so.6.7.3 + 0x182e40)
                #18 0x00007f611f7e145b n/a (/usr/lib/x86_64-linux-gnu/libQt6Gui.so.6.7.3 + 0x1e145b)
                #19 0x00007f611f8462dc n/a (/usr/lib/x86_64-linux-gnu/libQt6Gui.so.6.7.3 + 0x2462dc)
                #20 0x00007f611fd31a44 n/a (/usr/lib/x86_64-linux-gnu/libQt6Gui.so.6.7.3 + 0x731a44)
                #21 0x00007f611e219e59 n/a (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.6 + 0x60e59)
                #22 0x00007f611e2772b8 n/a (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.6 + 0xbe2b8)
                #23 0x00007f611e217513 n/a (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.6 + 0x5e513)
                #24 0x00007f611f27491f n/a (/usr/lib/x86_64-linux-gnu/libQt6Core.so.6.7.3 + 0x47491f)
                #25 0x00007f611ef8fa4b n/a (/usr/lib/x86_64-linux-gnu/libQt6Core.so.6.7.3 + 0x18fa4b)
                #26 0x00007f611ef8bc4d n/a (/usr/lib/x86_64-linux-gnu/libQt6Core.so.6.7.3 + 0x18bc4d)
                #27 0x000055cb6a546b52 n/a (/app/bin/kcalc + 0x25b52)
                #28 0x00007f611e83b08a n/a (/usr/lib/x86_64-linux-gnu/libc.so.6 + 0x2808a)
                #29 0x00007f611e83b14b n/a (/usr/lib/x86_64-linux-gnu/libc.so.6 + 0x2814b)
                #30 0x000055cb6a549465 n/a (/app/bin/kcalc + 0x28465)
                ELF object binary architecture: AMD x86-64
Comment 3 sebott 2024-10-16 08:54:21 UTC
(In reply to Gabriel Barrantes from comment #1)
> can't reproduce, did you get the "Syntax error" message? What version is the
> issue happening?

I didn't get any output..

kcalc --version
kcalc 24.08.2
Comment 4 Bug Janitor Service 2024-10-19 16:40:15 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kcalc/-/merge_requests/163
Comment 5 Gabriel Barrantes 2024-10-19 16:44:26 UTC
Some leftover dead code in the parser, it only happened when the first invalid character was "i". Fixed.
Comment 6 Gabriel Barrantes 2024-10-19 16:44:56 UTC
Git commit 8991af23ae24ccfa5cb48b4e986fc7b720402623 by Gabriel Barrantes.
Committed on 19/10/2024 at 16:37.
Pushed by gabrielbarrantes into branch 'master'.

Remove dead code for non implemented token

M  +0    -4    kcalc_parser.cpp

https://invent.kde.org/utilities/kcalc/-/commit/8991af23ae24ccfa5cb48b4e986fc7b720402623