Bug 410573

Summary: seg fault in focuser when trying to capture dark frame
Product: [Applications] kstars Reporter: boris
Component: generalAssignee: Jasem Mutlaq <mutlaqja>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: git   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 3.3.4
Sentry Crash Report:

Description boris 2019-08-04 13:28:35 UTC
SUMMARY
kstars see faults when taking dark frame in Ekos focuser. 

STEPS TO REPRODUCE
1. Dark Library needs to be empty (!)
2. Switch to Focuser tab, toggle "Dark Frame"
3. Click on "Capture Image"
4. In my case, a dialog appears: "Does ZWO CCD ASI224MC have a shutter?"
5. Click on "No"

OBSERVED RESULT
kstars windows disappear as the application has crashed.

Attaching gdb & repeating the steps will show the following on crash:

0x00ab2f8c in Ekos::DarkLibrary::<lambda()>::operator()(void) const (
    __closure=0x4daeaf8)
    at /home/pi/kde/kstars/kstars/ekos/auxiliary/darklibrary.cpp:372
372	                QString deviceName = targetChip->getCCD()->getDeviceName();

Given that targetChip is dereferenced a few lines ahead of this, I am assuming that getCCD() is returning something broken. I have no idea though, why that only happens with an empty "Dark Library". 

EXPECTED RESULT
kstars does not crash.

ADDITIONAL INFORMATION
- My (RPi) build is based on git commit 02fc8bfaf29b738d459ef1dfa1d11d52c4187d2f
- This also happens remotely controlling the RPi INDI drivers from MacOS. In that case, kstars 3.3.3 beta crashes at the same point.
Comment 1 boris 2019-08-04 13:44:33 UTC
Same things happens in the Guider module.
Comment 2 Jasem Mutlaq 2019-08-04 18:37:35 UTC
Git commit b17fe745338ed806620a21a7149e0a908e9ffa93 by Jasem Mutlaq.
Committed on 04/08/2019 at 18:36.
Pushed by mutlaqja into branch 'master'.

This should fix #410573 in addition to initial support for dust caps in Dark Library.
FIXED-IN:3.3.4

M  +121  -92   kstars/ekos/auxiliary/darklibrary.cpp
M  +8    -0    kstars/ekos/auxiliary/darklibrary.h
M  +4    -1    kstars/ekos/focus/focus.cpp
M  +13   -6    kstars/ekos/guide/guide.cpp
M  +41   -43   kstars/ekos/guide/internalguide/gmath.cpp
M  +6    -0    kstars/ekos/manager.cpp

https://commits.kde.org/kstars/b17fe745338ed806620a21a7149e0a908e9ffa93