svenstaro / rofi-calc

🖩 Do live calculations in rofi!
MIT License
964 stars 31 forks source link

Rofi calc crashes when trying to use any function with libqalculate 5 #117

Closed Wiian16 closed 5 months ago

Wiian16 commented 5 months ago

Version

Version: 1.7.5+wayland2-1-gff2338c3 (makepkg)

Distro

Archcraft x86_64

Command

rofi -show calc -modi calc -no-show-match -no-sort

This problem started after a system upgrade, this command did not change

Steps to reproduce

  1. Start using rofi calc
  2. Start typing any function (ex: cos, sin, integrate)
  3. Rofi calc crashes as soon as the function is typed out

Expected Behavior

Rofi calc shouldn't crash when using functions

Core dump

           PID: 5704 (rofi)
           UID: 1000 (wiian)
           GID: 1000 (wiian)
        Signal: 5 (TRAP)
     Timestamp: Sun 2024-03-17 18:16:14 EDT (7s ago)
  Command Line: rofi -show calc -modi calc -no-show-match -no-sort
    Executable: /usr/bin/rofi
 Control Group: /user.slice/user-1000.slice/session-2.scope
          Unit: session-2.scope
         Slice: user-1000.slice
       Session: 2
     Owner UID: 1000 (wiian)
       Boot ID: f4254d248e6349fe9579ad685647d96a
    Machine ID: 73f5a435776c43e19d07a6579e933bdb
      Hostname: ian-framework
       Storage: /var/lib/systemd/coredump/core.rofi.1000.f4254d248e6349fe9579ad685647d96a.5704.1710713774000000.zst (present)
  Size on Disk: 724.7K
       Message: Process 5704 (rofi) of user 1000 dumped core.

                Stack trace of thread 5704:
                #0  0x0000795fe45e42a8 g_log_structured_array (libglib-2.0.so.0 + 0x612a8)
                #1  0x0000795fe45e45a3 g_log_default_handler (libglib-2.0.so.0 + 0x615a3)
                #2  0x0000795fe45e5455 g_logv (libglib-2.0.so.0 + 0x62455)
                #3  0x0000795fe45e5724 g_log (libglib-2.0.so.0 + 0x62724)
                #4  0x0000795fe4701f54 n/a (calc.so + 0x2f54)
                #5  0x0000795fe4319d14 n/a (libgio-2.0.so.0 + 0xa9d14)
                #6  0x0000795fe4319d4d n/a (libgio-2.0.so.0 + 0xa9d4d)
                #7  0x0000795fe45dcf69 n/a (libglib-2.0.so.0 + 0x59f69)
                #8  0x0000795fe463b3a7 n/a (libglib-2.0.so.0 + 0xb83a7)
                #9  0x0000795fe45ddb97 g_main_loop_run (libglib-2.0.so.0 + 0x5ab97)
                #10 0x00005e6e380543d9 main (rofi + 0x1d3d9)
                #11 0x0000795fe3da7cd0 n/a (libc.so.6 + 0x25cd0)
                #12 0x0000795fe3da7d8a __libc_start_main (libc.so.6 + 0x25d8a)
                #13 0x00005e6e38054575 _start (rofi + 0x1d575)

                Stack trace of thread 5709:
                #0  0x0000795fe3e7d0bf __poll (libc.so.6 + 0xfb0bf)
                #1  0x0000795fe463b2f6 n/a (libglib-2.0.so.0 + 0xb82f6)
                #2  0x0000795fe45db162 g_main_context_iteration (libglib-2.0.so.0 + 0x58162)
                #3  0x0000795fe45db1b2 n/a (libglib-2.0.so.0 + 0x581b2)
                #4  0x0000795fe460ea45 n/a (libglib-2.0.so.0 + 0x8ba45)
                #5  0x0000795fe3e0d55a n/a (libc.so.6 + 0x8b55a)
                #6  0x0000795fe3e8aa3c n/a (libc.so.6 + 0x108a3c)

                Stack trace of thread 5711:
                #0  0x0000795fe3e8888d syscall (libc.so.6 + 0x10688d)
                #1  0x0000795fe4636337 g_cond_wait (libglib-2.0.so.0 + 0xb3337)
                #2  0x0000795fe45a81b4 n/a (libglib-2.0.so.0 + 0x251b4)
                #3  0x0000795fe45a821c g_async_queue_pop (libglib-2.0.so.0 + 0x2521c)
                #4  0x0000795fe37a6c48 n/a (libpangoft2-1.0.so.0 + 0x8c48)
                #5  0x0000795fe460ea45 n/a (libglib-2.0.so.0 + 0x8ba45)
                #6  0x0000795fe3e0d55a n/a (libc.so.6 + 0x8b55a)
                #7  0x0000795fe3e8aa3c n/a (libc.so.6 + 0x108a3c)

                Stack trace of thread 5710:
                #0  0x0000795fe3e7d0bf __poll (libc.so.6 + 0xfb0bf)
                #1  0x0000795fe463b2f6 n/a (libglib-2.0.so.0 + 0xb82f6)
                #2  0x0000795fe45ddb97 g_main_loop_run (libglib-2.0.so.0 + 0x5ab97)
                #3  0x0000795fe438219c n/a (libgio-2.0.so.0 + 0x11219c)
                #4  0x0000795fe460ea45 n/a (libglib-2.0.so.0 + 0x8ba45)
                #5  0x0000795fe3e0d55a n/a (libc.so.6 + 0x8b55a)
                #6  0x0000795fe3e8aa3c n/a (libc.so.6 + 0x108a3c)

                Stack trace of thread 5708:
                #0  0x0000795fe3e8888d syscall (libc.so.6 + 0x10688d)
                #1  0x0000795fe4636337 g_cond_wait (libglib-2.0.so.0 + 0xb3337)
                #2  0x0000795fe45a81b4 n/a (libglib-2.0.so.0 + 0x251b4)
                #3  0x0000795fe4610ace n/a (libglib-2.0.so.0 + 0x8dace)
                #4  0x0000795fe460ea45 n/a (libglib-2.0.so.0 + 0x8ba45)
                #5  0x0000795fe3e0d55a n/a (libc.so.6 + 0x8b55a)
                #6  0x0000795fe3e8aa3c n/a (libc.so.6 + 0x108a3c)
                ELF object binary architecture: AMD x86-64
svenstaro commented 5 months ago

Can reproduce. Sadly I have absolutely no idea why this happens all of a sudden. Do you have some time to dive into this perhaps? I'm not sure when I'll have time.

SuperDuperDeou commented 5 months ago

Same here. I've tried to git bisect, but I haven't found a good commit all the way back to v2.0.0. Probably something happened upstream.

Wiian16 commented 5 months ago

Unfortunately, I am not familiar with C, so I won't be much help. I can tell you that it was probably a recent package update that broke it, but I had a large amount of updates (122) during my last upgrade, so I may not be able to track it down.

CdRGit commented 5 months ago

managed to get some insight into it with GDB (really tricky to do considering how rofi works) and the error in calc appears to be happening here, but the traceback is less-than-ideal

CdRGit commented 5 months ago

one thing I did notice is that libqalculate on arch recently-ish updated, and appears to return the same exit code (1) as rofi-calc said the subprocess was returning when given an illegal expression (in my case 70p), is this taken into account?

Wiian16 commented 5 months ago

I downgraded my libqalculate to version 4.9.0, and that seems to have fixed the issue.

svenstaro commented 5 months ago

Somethings fucky with libqalculate 5 then. I don't really have time to dive into the specifics currently. I'd be very happy if someone could look into this. I'd be happy to review/merge/release.

CdRGit commented 5 months ago

so, I took the simplest test (-qalc-binary false) and it crashes when I type anything, I think the problem is that it doesn't handle it properly when the qalc-binary returns a non-zero exit code?

CdRGit commented 5 months ago

built libqalculate v4.9.0 from source, when pointing rofi-calc to that it works properly

...and as I suspected, v4.9.0, when given an invalid expression returns an exit code of 0, while v5 returns an exit code of 1

the program needs to be changed to properly handle the qalc-binary returning a non-zero exit code

132ikl commented 5 months ago

here's a temporary workaround:

create a new script named qalc in some directory in your PATH which appears before the directory the real qalc binary is. i chose ~/.local/bin/qalc. then just call the real qalc binary and then exit 0:

#!/usr/bin/env bash

/usr/bin/qalc "$@"
exit 0
revsuine commented 5 months ago

Also experiencing this. If I type sq (trying to type sqrt) it crashes like so (I think the warning is completely unrelated but just including all output):

** (process:85780): WARNING **: 22:45:08.529: Mode 'calc' does not have a type set. Please update mode/plugin.

** (process:85780): ERROR **: 22:45:10.225: Process errored with: Child process exited with code 1
[1]    85780 trace trap (core dumped)  rofi -show calc -modi calc -no-show-match -no-sort

I also get this crash when I type r and nothing else:

** (process:87212): WARNING **: 22:47:42.492: Mode 'calc' does not have a type set. Please update mode/plugin.

** (process:87212): ERROR **: 22:47:43.100: Process errored with: Child process exited with code 1
[1]    87212 trace trap (core dumped)  rofi -show calc -modi calc -no-show-match -no-sort

Distro: Arch
Rofi fork: lbonn's Wayland fork, version 1.7.5+wayland3-1
rofi-calc version: 2.2.0-1

Celibistrial commented 5 months ago

same issue on NixOS unstable can be solved be using downgrading libqalculate using overlays

# Add this to configuration.nix
  nixpkgs.overlays = [
    (final: prev: {
      # see https://github.com/svenstaro/rofi-calc/issues/117
      libqalculate = prev.libqalculate.overrideAttrs (_: rec {
        pname = "libqalculate";
        version = "4.8.1";

        src = pkgs.fetchFromGitHub {
          owner = "qalculate";
          repo = "libqalculate";
          rev = "v${version}";
          sha256 = "sha256-4WqKlwVf4/ixVr98lPFVfNL6EOIfHHfL55xLsYqxkhY=";
        };
      });
    })
  ];
svenstaro commented 5 months ago

Fixed by cc6cd37ac64a54f7cee8309a63f5eb7f9c9745f1.