<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hm, tricky, this looks like a problem that we need to solve more generally. Obviously, using one simple pointer for the active job is not thread safe. In Java, I would solve this with a accessor function that throws a specific exception, that can be caught in a central place. But I’m not sure what the appropriate answer in C++ is...<div class=""><br class=""></div><div class="">But anyway, let’s start developing a solution for it like we did it with all the other edge cases: step 1 is to develop a test case that (more or less) makes this problem reproducible. A good starting point could be extending TestEkosCaptureWorkflow, which I created a couple of weeks ago.</div><div class=""><br class=""></div><div class="">Hy, could you give it a try? I could assist…</div><div class=""><br class=""></div><div class="">Wolfgang<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">Am 13.08.2021 um 06:02 schrieb Hy Murveit <<a href="mailto:murveit@gmail.com" class="">murveit@gmail.com</a>>:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><b class="">TL;DR</b></div><div class=""><br class=""></div><div class="">I got a segv in bad weather the other night.</div><div class="">I did trace down what caused it, see below, but I think I should leave the solution to someone more experienced in the intricacies of capture (e.g. Wolfgang or Jasem).</div><div class=""><br class=""></div><div class=""><b class="">Why it crashed:</b></div><div class=""><br class=""></div><div class="">You can see the end of the log below (log stops on segv after these 20 lines).</div><div class="">You can also see the backtrace below it.</div><br class="">Bottom line, it's clear from the gdb backtrace that it dies in Capture::setCaptureComplete(), and I believe it died trying to reference the activeJob variable<br class="">which is set to nullptr because of Guiding state changed from "Reacquiring" to "Aborted.<br class=""><br class=""><div class="">When the guiding state changed from "Reacquiring" to "Aborted" in setGuideStatus(). </div><div class="">- it called processGuidingFailed(), </div><div class="">- which called abort()</div><div class="">- which called stop() </div><div class="">- which sets activeJob = nullptr.</div><div class=""><br class=""></div><div class="">Meanwhile, while all that was happening, setCaptureComplete was waiting for the solver to run:</div><div class=""> QFuture<bool> result = m_ImageData->findStars(ALGORITHM_SEP);<br class=""> result.waitForFinished();<br class=""></div><div class=""><br class=""></div><div class="">and while it was waiting, activeJob was set to nullptr but the guiding status change. So, after the wait completed, setCaptureComplete</div><div class="">probably failed onemit captureComplete(filename, activeJob->getFilterName(), ...)</div><div class="">or perhaps below that on "if (activeJob->getCount())" </div><div class="">because activeJob is now nullptr.</div><div class=""><br class=""></div><div class=""><b class="">Solution:</b></div><div class=""><b class=""><br class=""></b></div><div class="">We could simply protect the access of activeJob by testing if it's not null.</div><div class="">That would certainly work for the emit captureComplete (just don't emit it if guiding has failed).</div><div class=""><br class=""></div><div class="">However, I'm not sure what to do about the second access.</div><div class="">Should it just do this both places?</div><div class=""><br class=""></div><div class="">if (activeJob == nullptr) return IPS_OK;</div><div class=""><br class=""></div><div class="">Anyway, I'll leave this for Jasem and/or Wolfgang.</div><div class=""><br class=""></div><div class="">Hy</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">[2021-08-12T02:28:23.284 PDT INFO ][ org.kde.kstars.ekos.capture] - "Received image 16 out of 60."<br class="">[2021-08-12T02:28:23.286 PDT DEBG ][ org.kde.kstars.fits] - Sextract with: "1-HFR-Default"<br class="">[2021-08-12T02:28:23.580 PDT DEBG ][ org.kde.kstars.indi] - Image received. Mode: "Guide" Size: 313920<br class="">[2021-08-12T02:28:23.581 PDT DEBG ][ org.kde.kstars.fits] - Reading file buffer ( "306.6 KiB" )<br class="">[2021-08-12T02:28:23.614 PDT DEBG ][ org.kde.kstars.ekos.guide] - Received guide frame.<br class="">[2021-08-12T02:28:23.614 PDT DEBG ][ org.kde.kstars.ekos.guide] - Multistar: findTopStars 10<br class="">[2021-08-12T02:28:23.615 PDT DEBG ][ org.kde.kstars.fits] - Sextract with: "1-Guide-Default"<br class="">[2021-08-12T02:28:23.679 PDT DEBG ][ org.kde.kstars.indi] - Rainbow Astro RSF : "[DEBUG] CMD <:Fp#> "<br class="">[2021-08-12T02:28:23.679 PDT DEBG ][ org.kde.kstars.indi] - Rainbow Astro RSF : "[DEBUG] RES <:FP-04.815#> "<br class="">[2021-08-12T02:28:23.700 PDT DEBG ][ org.kde.kstars.ekos.scheduler] - Scheduler iteration never set up.<br class="">[2021-08-12T02:28:23.708 PDT DEBG ][ org.kde.kstars.ekos.guide] - "Select # x y flux HFR SNR score"<br class="">[2021-08-12T02:28:23.708 PDT DEBG ][ org.kde.kstars.ekos.guide] - No suitable star detected.<br class="">[2021-08-12T02:28:23.708 PDT INFO ][ org.kde.kstars.ekos.guide] - "Failed to find any suitable guide stars. Aborting..."<br class="">[2021-08-12T02:28:23.709 PDT DEBG ][ org.kde.kstars.ekos.capture] -<span style="background-color:rgb(255,255,0)" class=""> Guiding state changed from "Reacquiring" to "Aborted"</span><br class="">[2021-08-12T02:28:23.710 PDT INFO ][ org.kde.kstars.ekos.capture] - "Autoguiding stopped. Aborting..."<br class="">[2021-08-12T02:28:23.768 PDT INFO ][ org.kde.kstars.ekos.capture] - "CCD capture aborted"<br class="">[2021-08-12T02:28:23.770 PDT DEBG ][ org.kde.kstars.ekos.guide] - Reset non guiding dithering position<br class="">[2021-08-12T02:28:23.771 PDT DEBG ][ org.kde.kstars.ekos.capture] - setMeridianFlipStage: "MF_READY"<br class="">[2021-08-12T02:28:23.837 PDT INFO ][ org.kde.kstars.ekos.guide] - "Autoguiding aborted."<br class="">[2021-08-12T02:28:23.837 PDT DEBG ][ org.kde.kstars.ekos.guide] - Aborting "Reacquiring"<br class="">> <br class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div>(gdb) bt<br class="">#0 0x0000aaaaaafcfe64 in Ekos::Capture::b() (this=this@entry=0xaaaab68c02b0)<br class=""> at /home/hy/Projects/kstars/kstars/ekos/capture/sequencejob.h:153<br class="">#1 0x0000aaaaaafd0b70 in Ekos::Capture::processData(QSharedPointer<FITSData> const&) (this=0xaaaab68c02b0, data=...)<br class=""> at /home/hy/Projects/kstars/kstars/ekos/capture/capture.cpp:1700<br class="">#2 0x0000fffff5416d5c in () at /lib/aarch64-linux-gnu/libQt5Core.so.5<br class="">#3 0x0000aaaaaaddbe68 in ISD::CCD::newImage(QSharedPointer<FITSData> const&) (this=this@entry=0xaaaaafe245c0, _t1=...)<br class=""> at /home/hy/Projects/kstars-build/kstars/KStarsLib_autogen/FRI4DANIHA/moc_indiccd.cpp:413<br class="">#4 0x0000aaaaaaea668c in ISD::CCD::handleImage(ISD::CCDChip*, QString const&, _IBLOB*, QSharedPointer<FITSData>)<br class=""> (this=this@entry=0xaaaaafe245c0, targetChip=targetChip@entry=0xaaaab1a8dca0, filename=..., bp=bp@entry=0xffff94014950, data=...) at /home/hy/Projects/kstars/kstars/indi/indiccd.cpp:1699<br class="">#5 0x0000aaaaaaead8d0 in ISD::CCD::processBLOB(_IBLOB*) (this=0xaaaaafe245c0, bp=0xffff94014950)<br class=""> at /usr/include/c++/10/bits/atomic_base.h:325<br class="">#6 0x0000fffff5416d5c in () at /lib/aarch64-linux-gnu/libQt5Core.so.5<br class="">#7 0x0000aaaaaaddd1cc in ClientManager::newINDIBLOB(_IBLOB*) (this=<optimized out>, _t1=<optimized out>)<br class=""> at /home/hy/Projects/kstars-build/kstars/KStarsLib_autogen/FRI4DANIHA/moc_clientmanager.cpp:369<br class="">#8 0x0000fffff540cbfc in QObject::event(QEvent*) () at /lib/aarch64-linux-gnu/libQt5Core.so.5<br class="">#9 0x0000fffff5e1a480 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()<br class=""> at /lib/aarch64-linux-gnu/libQt5Widgets.so.5<br class="">#10 0x0000fffff53dc56c in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /lib/aarch64-linux-gnu/libQt5Core.so.5<br class="">#11 0x0000fffff53df2c8 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()<br class=""> at /lib/aarch64-linux-gnu/libQt5Core.so.5<br class="">#12 0x0000fffff543ae68 in () at /lib/aarch64-linux-gnu/libQt5Core.so.5<br class="">#13 0x0000fffff4410c30 in g_main_context_dispatch () at /lib/aarch64-linux-gnu/libglib-2.0.so.0<br class="">#14 0x0000fffff4410ec8 in () at /lib/aarch64-linux-gnu/libglib-2.0.so.0<br class="">#15 0x0000fffff4410f94 in g_main_context_iteration () at /lib/aarch64-linux-gnu/libglib-2.0.so.0<br class="">#16 0x0000fffff543a304 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()<br class=""> at /lib/aarch64-linux-gnu/libQt5Core.so.5<br class="">#17 0x0000fffff53da97c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()<br class=""> at /lib/aarch64-linux-gnu/libQt5Core.so.5<br class="">#18 0x0000fffff53e3a7c in QCoreApplication::exec() () at /lib/aarch64-linux-gnu/libQt5Core.so.5<br class="">#19 0x0000aaaaaab9956c in main(int, char**) (argc=<optimized out>, argv=<optimized out>)<br class=""> at /home/hy/Projects/kstars/kstars/main.cpp:393<br class="">(gdb) <br class=""><br class=""><div class=""><br class=""></div><div class=""><br class=""></div></div>
</div></blockquote></div><br class=""></div></body></html>