rlancaste / stellarsolver

GNU General Public License v3.0
89 stars 47 forks source link

astrometry.log prints double values incorrectly on ARM 32bit #75

Closed ken-self closed 2 years ago

ken-self commented 3 years ago

Whenever a double precision value is written to the log a crazy number is printed. Affects users of Kstars on 32bit ARM like astroberry It can be resolved by sprintf into a string followed by printf of the string but I imagine there is a compiler/linker option that might resolve it. Not sure if it has any other flow on effect. Solving seems to work ok although I came across this helping another user whowas experiencing intermittent crashes when solving. The same values in the Kstars log look ok. When astroberry is upgraded to 64 bit the issue should disappear. I do recall a similar issue with the Avalon driver where printf of a double value requires the format to be %lf instead of %f to avoid a crash on RPi. Google search shows a history of this issue or similar but no clear resolution and lots of red herrings. I was able to reporduce the issue on Ubuntu 20.04 32 bit on RPi3 and with Ubuntu 20.04 64bit the log values print correctly astrometrylog.txt

rlancaste commented 3 years ago

Yes that definitely looks like there was an overflow issue with the 32bit int somewhere based on those numbers. But the question would be whether that is caused by the underlying astrometry.net code, whether it was just an issue with either KStars or stellarsolver at a higher level, or if it was just an issue with printing.

Do you by any chance have a file that produces these strange numbers when solving?

ken-self commented 3 years ago

It seems to happen with any image but here is the one I was using. 32MB so I've loaded to Google Drive at: https://drive.google.com/file/d/1ZtMgl2IqTefz6pcSa3ZOICiAUDywFHR4/view?usp=sharing I experimented with inserting a sprintf to a char string then call printf %s on a couple of spots and that gave the correct printed value; so I think the problem is primarily in printf. And the equivalent values printed in the KStars log look correct. At the time I was chasing down the cause of the solver crashing (probably out of memory) but this issues was clouding the cause of the crash.

rlancaste commented 2 years ago

So I just fixed this with a rather big commit. I rewrote the astrometry.net logging functions as part of a bigger fix of some other issues. In the process, this issue seems to have gone away. It now outputs correct numbers into the log. And in fact, I have improved the logging methods so that you can actually view the whole log efficiently in the GUI now.