ahodesuka / ahoviewer

A GTK image viewer, manga reader, and booru browser
MIT License
479 stars 30 forks source link

Crashes upon search after running OS updates #136

Closed Tuerai closed 2 years ago

Tuerai commented 2 years ago

Ahoviewer version: 1.6.5-231-g2eb22dd

OS: Arch Linux, kernel 5.10.90-1

After I ran updates (had been a few months) and rebooted, now ahoviewer crashes upon searching any term after loading for a second. I tried doing a git pull to get the latest sources, and then rebuilt with those per the steps on here (normally I just use the AUR package) and I still had the same problem after doing a fresh build as well.

I setup core dumps, and looked at it a little with gdb, and it seems like maybe it could be an issue with my version of libcurl?

If you'd like some different GDB output, or any other info, I would be happy to provide them. Here's the GDB output I grabbed from the core file I generated so far: gdb.txt https://ghostbin.com/eFqTF/raw

I have the core file too if you want it, but I'm not sure where the best place to upload it is.

OrdinaryMagician commented 2 years ago

Also segfaulting on libcurl here. Downgrading the curl package to 7.80.0 from 7.81.0 does prevent the crash, though. The issue was definitely introduced by that version.

ahodesuka commented 2 years ago

I looked through curl's 7.81.0 changes and there were a few to the curl multi interface. I'll have to do my own testing before I can see how to fix it, or if it's an upstream bug.

Pizzabelly commented 2 years ago

I think it's caused by this: https://github.com/ahodesuka/ahoviewer/blob/master/src/booru/imagefetcher.cc#L52 In curl it can cause errors if you call some curl functions from a curl callback. Which happens here if the timeout_ms is 0.

diff --git a/src/booru/imagefetcher.cc b/src/booru/imagefetcher.cc
index 9e1e81f..0182422 100644
--- a/src/booru/imagefetcher.cc
+++ b/src/booru/imagefetcher.cc
@@ -45,11 +45,9 @@ int ImageFetcher::timer_cb(CURLM*, long timeout_ms, void* userp)
 {
     auto* self{ static_cast<ImageFetcher*>(userp) };

-    if (timeout_ms > 0)
+    if (timeout_ms >= 0)
         self->m_TimeoutConn = self->m_MainContext->signal_timeout().connect(
             sigc::mem_fun(self, &ImageFetcher::timeout_cb), timeout_ms);
-    else if (timeout_ms == 0)
-        self->timeout_cb();
     else if (timeout_ms == -1 && self->m_TimeoutConn)
         self->m_TimeoutConn.disconnect();

This fixes the issue for me, but maybe there's a better solution.

ahodesuka commented 2 years ago

Okay this was certainly a bug in ahoviewer then. ce4f2ab should fix the problem and have no effect for anyone using older versions of curl.