[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kstars-devel
Subject:    segv in setCaptureComplete
From:       Hy Murveit <murveit () gmail ! com>
Date:       2021-08-13 4:02:37
Message-ID: CA+B1P8tMwbaMz2Wq4aOPyJzswGGr4s9A8P7Ly9JWPZA4u61A6w () mail ! gmail ! com
[Download RAW message or body]

*TL;DR*

I got a segv in bad weather the other night.
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).

*Why it crashed:*

You can see the end of the log below (log stops on segv after these 20
lines).
You can also see the backtrace below it.

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
which is set to nullptr because of Guiding state changed from "Reacquiring"
to "Aborted.

When the guiding state changed from  "Reacquiring" to "Aborted" in
setGuideStatus().
- it called processGuidingFailed(),
- which called abort()
- which called stop()
- which sets activeJob = nullptr.

Meanwhile, while all that was happening, setCaptureComplete was waiting for
the solver to run:
            QFuture<bool> result = m_ImageData->findStars(ALGORITHM_SEP);
            result.waitForFinished();

and while it was waiting, activeJob was set to nullptr but the guiding
status change.  So, after the wait completed, setCaptureComplete
probably failed onemit captureComplete(filename,
activeJob->getFilterName(), ...)
or perhaps below that on "if (activeJob->getCount())"
because activeJob is now nullptr.

*Solution:*

We could simply protect the access of activeJob by testing if it's not null.
That would certainly work for the emit captureComplete (just don't emit it
if guiding has failed).

However, I'm not sure what to do about the second access.
Should it just do this both places?

if (activeJob == nullptr) return IPS_OK;

Anyway, I'll leave this for Jasem and/or Wolfgang.

Hy



[2021-08-12T02:28:23.284 PDT INFO ][   org.kde.kstars.ekos.capture] -
"Received image 16 out of 60."
[2021-08-12T02:28:23.286 PDT DEBG ][           org.kde.kstars.fits] -
Sextract with:  "1-HFR-Default"
[2021-08-12T02:28:23.580 PDT DEBG ][           org.kde.kstars.indi] - Image
received. Mode: "Guide" Size: 313920
[2021-08-12T02:28:23.581 PDT DEBG ][           org.kde.kstars.fits] -
Reading file buffer ( "306.6 KiB" )
[2021-08-12T02:28:23.614 PDT DEBG ][     org.kde.kstars.ekos.guide] -
Received guide frame.
[2021-08-12T02:28:23.614 PDT DEBG ][     org.kde.kstars.ekos.guide] -
Multistar: findTopStars 10
[2021-08-12T02:28:23.615 PDT DEBG ][           org.kde.kstars.fits] -
Sextract with:  "1-Guide-Default"
[2021-08-12T02:28:23.679 PDT DEBG ][           org.kde.kstars.indi] -
Rainbow Astro RSF : "[DEBUG] CMD <:Fp#> "
[2021-08-12T02:28:23.679 PDT DEBG ][           org.kde.kstars.indi] -
Rainbow Astro RSF : "[DEBUG] RES <:FP-04.815#> "
[2021-08-12T02:28:23.700 PDT DEBG ][ org.kde.kstars.ekos.scheduler] -
Scheduler iteration never set up.
[2021-08-12T02:28:23.708 PDT DEBG ][     org.kde.kstars.ekos.guide] -
"Select      #   x      y      flux    HFR  SNR   score"
[2021-08-12T02:28:23.708 PDT DEBG ][     org.kde.kstars.ekos.guide] - No
suitable star detected.
[2021-08-12T02:28:23.708 PDT INFO ][     org.kde.kstars.ekos.guide] -
"Failed to find any suitable guide stars. Aborting..."
[2021-08-12T02:28:23.709 PDT DEBG ][   org.kde.kstars.ekos.capture] -
Guiding state changed from "Reacquiring" to "Aborted"
[2021-08-12T02:28:23.710 PDT INFO ][   org.kde.kstars.ekos.capture] -
"Autoguiding stopped. Aborting..."
[2021-08-12T02:28:23.768 PDT INFO ][   org.kde.kstars.ekos.capture] - "CCD
capture aborted"
[2021-08-12T02:28:23.770 PDT DEBG ][     org.kde.kstars.ekos.guide] - Reset
non guiding dithering position
[2021-08-12T02:28:23.771 PDT DEBG ][   org.kde.kstars.ekos.capture] -
setMeridianFlipStage:  "MF_READY"
[2021-08-12T02:28:23.837 PDT INFO ][     org.kde.kstars.ekos.guide] -
"Autoguiding aborted."
[2021-08-12T02:28:23.837 PDT DEBG ][     org.kde.kstars.ekos.guide] -
Aborting "Reacquiring"
>




(gdb) bt
#0  0x0000aaaaaafcfe64 in Ekos::Capture::b() (this=this@entry
=0xaaaab68c02b0)
    at /home/hy/Projects/kstars/kstars/ekos/capture/sequencejob.h:153
#1  0x0000aaaaaafd0b70 in
Ekos::Capture::processData(QSharedPointer<FITSData> const&)
(this=0xaaaab68c02b0, data=...)
    at /home/hy/Projects/kstars/kstars/ekos/capture/capture.cpp:1700
#2  0x0000fffff5416d5c in  () at /lib/aarch64-linux-gnu/libQt5Core.so.5
#3  0x0000aaaaaaddbe68 in ISD::CCD::newImage(QSharedPointer<FITSData>
const&) (this=this@entry=0xaaaaafe245c0, _t1=...)
    at
/home/hy/Projects/kstars-build/kstars/KStarsLib_autogen/FRI4DANIHA/moc_indiccd.cpp:413
#4  0x0000aaaaaaea668c in ISD::CCD::handleImage(ISD::CCDChip*, QString
const&, _IBLOB*, QSharedPointer<FITSData>)
    (this=this@entry=0xaaaaafe245c0,
targetChip=targetChip@entry=0xaaaab1a8dca0,
filename=..., bp=bp@entry=0xffff94014950, data=...) at
/home/hy/Projects/kstars/kstars/indi/indiccd.cpp:1699
#5  0x0000aaaaaaead8d0 in ISD::CCD::processBLOB(_IBLOB*)
(this=0xaaaaafe245c0, bp=0xffff94014950)
    at /usr/include/c++/10/bits/atomic_base.h:325
#6  0x0000fffff5416d5c in  () at /lib/aarch64-linux-gnu/libQt5Core.so.5
#7  0x0000aaaaaaddd1cc in ClientManager::newINDIBLOB(_IBLOB*)
(this=<optimized out>, _t1=<optimized out>)
    at
/home/hy/Projects/kstars-build/kstars/KStarsLib_autogen/FRI4DANIHA/moc_clientmanager.cpp:369
#8  0x0000fffff540cbfc in QObject::event(QEvent*) () at
/lib/aarch64-linux-gnu/libQt5Core.so.5
#9  0x0000fffff5e1a480 in QApplicationPrivate::notify_helper(QObject*,
QEvent*) ()
    at /lib/aarch64-linux-gnu/libQt5Widgets.so.5
#10 0x0000fffff53dc56c in QCoreApplication::notifyInternal2(QObject*,
QEvent*) () at /lib/aarch64-linux-gnu/libQt5Core.so.5
#11 0x0000fffff53df2c8 in
QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
    at /lib/aarch64-linux-gnu/libQt5Core.so.5
#12 0x0000fffff543ae68 in  () at /lib/aarch64-linux-gnu/libQt5Core.so.5
#13 0x0000fffff4410c30 in g_main_context_dispatch () at
/lib/aarch64-linux-gnu/libglib-2.0.so.0
#14 0x0000fffff4410ec8 in  () at /lib/aarch64-linux-gnu/libglib-2.0.so.0
#15 0x0000fffff4410f94 in g_main_context_iteration () at
/lib/aarch64-linux-gnu/libglib-2.0.so.0
#16 0x0000fffff543a304 in
QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)
()
    at /lib/aarch64-linux-gnu/libQt5Core.so.5
#17 0x0000fffff53da97c in
QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /lib/aarch64-linux-gnu/libQt5Core.so.5
#18 0x0000fffff53e3a7c in QCoreApplication::exec() () at
/lib/aarch64-linux-gnu/libQt5Core.so.5
#19 0x0000aaaaaab9956c in main(int, char**) (argc=<optimized out>,
argv=<optimized out>)
    at /home/hy/Projects/kstars/kstars/main.cpp:393
(gdb)

[Attachment #3 (text/html)]

<div dir="ltr"><div><b>TL;DR</b></div><div><br></div><div>I got a segv in bad weather \
the other night.</div><div>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><br></div><div><b>Why it \
crashed:</b></div><div><br></div><div>You can see the end of the log below (log stops \
on segv after these 20 lines).</div><div>You can also see the backtrace below \
it.</div><br>Bottom line, it&#39;s clear from the gdb backtrace that it dies in \
Capture::setCaptureComplete(), and I believe it died trying to reference the \
activeJob variable<br>which is set to nullptr because of Guiding state changed from \
&quot;Reacquiring&quot; to &quot;Aborted.<br><br><div>When the guiding state changed \
from   &quot;Reacquiring&quot; to &quot;Aborted&quot; in setGuideStatus().  \
</div><div>- it called processGuidingFailed(),  </div><div>- which called \
abort()</div><div>- which called stop()  </div><div>- which sets activeJob = \
nullptr.</div><div><br></div><div>Meanwhile, while all that was happening, \
setCaptureComplete was waiting for the solver to run:</div><div>                  \
QFuture&lt;bool&gt; result = m_ImageData-&gt;findStars(ALGORITHM_SEP);<br>            \
result.waitForFinished();<br></div><div><br></div><div>and while it was waiting, \
activeJob was set to nullptr but the guiding status change.   So, after the wait \
completed, setCaptureComplete</div><div>probably failed onemit \
captureComplete(filename, activeJob-&gt;getFilterName(), ...)</div><div>or perhaps \
below that on &quot;if (activeJob-&gt;getCount())&quot;  </div><div>because activeJob \
is now nullptr.</div><div><br></div><div><b>Solution:</b></div><div><b><br></b></div><div>We \
could simply protect the access of activeJob by testing if it&#39;s not \
null.</div><div>That would certainly work for the emit captureComplete (just \
don&#39;t emit it if guiding has failed).</div><div><br></div><div>However, I&#39;m \
not sure what to do about the second access.</div><div>Should it just do this both \
places?</div><div><br></div><div>if (activeJob == nullptr) return \
IPS_OK;</div><div><br></div><div>Anyway, I&#39;ll leave this for Jasem and/or \
Wolfgang.</div><div><br></div><div>Hy</div><div><br></div><div><br></div><div><br></div><div>[2021-08-12T02:28:23.284 \
PDT INFO ][    org.kde.kstars.ekos.capture] - &quot;Received image 16 out of \
60.&quot;<br>[2021-08-12T02:28:23.286 PDT DEBG ][                org.kde.kstars.fits] \
- Sextract with:   &quot;1-HFR-Default&quot;<br>[2021-08-12T02:28:23.580 PDT DEBG ][  \
org.kde.kstars.indi] - Image received. Mode: &quot;Guide&quot; Size: \
313920<br>[2021-08-12T02:28:23.581 PDT DEBG ][                org.kde.kstars.fits] - \
Reading file buffer ( &quot;306.6 KiB&quot; )<br>[2021-08-12T02:28:23.614 PDT DEBG ][ \
org.kde.kstars.ekos.guide] - Received guide frame.<br>[2021-08-12T02:28:23.614 PDT \
DEBG ][       org.kde.kstars.ekos.guide] - Multistar: findTopStars \
10<br>[2021-08-12T02:28:23.615 PDT DEBG ][                org.kde.kstars.fits] - \
Sextract with:   &quot;1-Guide-Default&quot;<br>[2021-08-12T02:28:23.679 PDT DEBG ][  \
org.kde.kstars.indi] - Rainbow Astro RSF : &quot;[DEBUG] CMD &lt;:Fp#&gt; \
&quot;<br>[2021-08-12T02:28:23.679 PDT DEBG ][                org.kde.kstars.indi] - \
Rainbow Astro RSF : &quot;[DEBUG] RES &lt;:FP-04.815#&gt; \
&quot;<br>[2021-08-12T02:28:23.700 PDT DEBG ][ org.kde.kstars.ekos.scheduler] - \
Scheduler iteration never set up.<br>[2021-08-12T02:28:23.708 PDT DEBG ][       \
org.kde.kstars.ekos.guide] - &quot;Select         #    x         y         flux      \
HFR   SNR    score&quot;<br>[2021-08-12T02:28:23.708 PDT DEBG ][       \
org.kde.kstars.ekos.guide] - No suitable star detected.<br>[2021-08-12T02:28:23.708 \
PDT INFO ][       org.kde.kstars.ekos.guide] - &quot;Failed to find any suitable \
guide stars. Aborting...&quot;<br>[2021-08-12T02:28:23.709 PDT DEBG ][    \
org.kde.kstars.ekos.capture] -<span style="background-color:rgb(255,255,0)"> Guiding \
state changed from &quot;Reacquiring&quot; to \
&quot;Aborted&quot;</span><br>[2021-08-12T02:28:23.710 PDT INFO ][    \
org.kde.kstars.ekos.capture] - &quot;Autoguiding stopped. \
Aborting...&quot;<br>[2021-08-12T02:28:23.768 PDT INFO ][    \
org.kde.kstars.ekos.capture] - &quot;CCD capture \
aborted&quot;<br>[2021-08-12T02:28:23.770 PDT DEBG ][       \
org.kde.kstars.ekos.guide] - Reset non guiding dithering \
position<br>[2021-08-12T02:28:23.771 PDT DEBG ][    org.kde.kstars.ekos.capture] - \
setMeridianFlipStage:   &quot;MF_READY&quot;<br>[2021-08-12T02:28:23.837 PDT INFO ][  \
org.kde.kstars.ekos.guide] - &quot;Autoguiding \
aborted.&quot;<br>[2021-08-12T02:28:23.837 PDT DEBG ][       \
org.kde.kstars.ekos.guide] - Aborting &quot;Reacquiring&quot;<br>&gt; \
<br><br></div><div><br></div><div><br></div><div><br></div>(gdb) bt<br>#0   \
0x0000aaaaaafcfe64 in Ekos::Capture::b() (this=this@entry=0xaaaab68c02b0)<br>      at \
/home/hy/Projects/kstars/kstars/ekos/capture/sequencejob.h:153<br>#1   \
0x0000aaaaaafd0b70 in Ekos::Capture::processData(QSharedPointer&lt;FITSData&gt; \
const&amp;) (this=0xaaaab68c02b0, data=...)<br>      at \
/home/hy/Projects/kstars/kstars/ekos/capture/capture.cpp:1700<br>#2   \
0x0000fffff5416d5c in   () at /lib/aarch64-linux-gnu/libQt5Core.so.5<br>#3   \
0x0000aaaaaaddbe68 in ISD::CCD::newImage(QSharedPointer&lt;FITSData&gt; const&amp;) \
(this=this@entry=0xaaaaafe245c0, _t1=...)<br>      at \
/home/hy/Projects/kstars-build/kstars/KStarsLib_autogen/FRI4DANIHA/moc_indiccd.cpp:413<br>#4 \
0x0000aaaaaaea668c in ISD::CCD::handleImage(ISD::CCDChip*, QString const&amp;, \
_IBLOB*, QSharedPointer&lt;FITSData&gt;)<br>      (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>#5   \
0x0000aaaaaaead8d0 in ISD::CCD::processBLOB(_IBLOB*) (this=0xaaaaafe245c0, \
bp=0xffff94014950)<br>      at /usr/include/c++/10/bits/atomic_base.h:325<br>#6   \
0x0000fffff5416d5c in   () at /lib/aarch64-linux-gnu/libQt5Core.so.5<br>#7   \
0x0000aaaaaaddd1cc in ClientManager::newINDIBLOB(_IBLOB*) (this=&lt;optimized \
out&gt;, _t1=&lt;optimized out&gt;)<br>      at \
/home/hy/Projects/kstars-build/kstars/KStarsLib_autogen/FRI4DANIHA/moc_clientmanager.cpp:369<br>#8 \
0x0000fffff540cbfc in QObject::event(QEvent*) () at \
/lib/aarch64-linux-gnu/libQt5Core.so.5<br>#9   0x0000fffff5e1a480 in \
QApplicationPrivate::notify_helper(QObject*, QEvent*) ()<br>      at \
/lib/aarch64-linux-gnu/libQt5Widgets.so.5<br>#10 0x0000fffff53dc56c in \
QCoreApplication::notifyInternal2(QObject*, QEvent*) () at \
/lib/aarch64-linux-gnu/libQt5Core.so.5<br>#11 0x0000fffff53df2c8 in \
QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()<br>      at \
/lib/aarch64-linux-gnu/libQt5Core.so.5<br>#12 0x0000fffff543ae68 in   () at \
/lib/aarch64-linux-gnu/libQt5Core.so.5<br>#13 0x0000fffff4410c30 in \
g_main_context_dispatch () at /lib/aarch64-linux-gnu/libglib-2.0.so.0<br>#14 \
0x0000fffff4410ec8 in   () at /lib/aarch64-linux-gnu/libglib-2.0.so.0<br>#15 \
0x0000fffff4410f94 in g_main_context_iteration () at \
/lib/aarch64-linux-gnu/libglib-2.0.so.0<br>#16 0x0000fffff543a304 in \
QEventDispatcherGlib::processEvents(QFlags&lt;QEventLoop::ProcessEventsFlag&gt;) \
()<br>      at /lib/aarch64-linux-gnu/libQt5Core.so.5<br>#17 0x0000fffff53da97c in \
QEventLoop::exec(QFlags&lt;QEventLoop::ProcessEventsFlag&gt;) ()<br>      at \
/lib/aarch64-linux-gnu/libQt5Core.so.5<br>#18 0x0000fffff53e3a7c in \
QCoreApplication::exec() () at /lib/aarch64-linux-gnu/libQt5Core.so.5<br>#19 \
0x0000aaaaaab9956c in main(int, char**) (argc=&lt;optimized out&gt;, \
argv=&lt;optimized out&gt;)<br>      at \
/home/hy/Projects/kstars/kstars/main.cpp:393<br>(gdb) \
<br><br><div><br></div><div><br></div></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic