cytan299 / field_derotator

A Field DeRotator for Alt-Az Mounted Telescopes Used for Astrophotography
GNU General Public License v3.0
32 stars 4 forks source link

Compiling under Linux #4

Closed roboticboyer closed 5 years ago

roboticboyer commented 5 years ago

Good Morning I compiled the Front-end under Linux Mint 19.1 with some minor changes on the Make file ( I can share the file if requested)

Starting the program, it close immediately with this error message (I can see the GUI only for 1 second)

segmentation fault

The dump of the error is:

0x00005555555d197c in gl_draw(char const*, int) ()

The issue is the below line of code DeRotatorGraphics.cpp 432: gl_draw(buf, -14.0f, -9.5f );

https://github.com/cytan299/field_derotator/blob/4f215db3dadfd8cf80bc349a19b55723e4416fad/frontend/derot/DeRotatorGraphics.cpp#L432

I commented the line and the program started to work but I lost the "angle of the derotator"

I'm not expert about FLTK library. Do you know how to fix it? I think it's something related to the type (float or int) of the x and y coordinates

I'm using the version 1.3.4 of the FLTK library as suggested

Thank you for the support Gio

cytan299 commented 5 years ago

Hi Gio, I've run derot through lldb and I did not see it crash. I would suggest that you recompile with the line uncommented. I believe the Makefile has -g enabled so that you can use lldb to see what's going on. Break at line 432 and print out buf. You should see something like this:

track

If it crashes again, try seeing exactly where by doing thread backtrace

to see where you are that actually caused the crash.

You may have to enable debugging in FLTK as well so that it will be clear where the problem is.

P.S. there is this odd ball warning that CGContextSaveGState invalid context 0x0 which may be the actual problem. But this doesn't crash on my Mac.

roboticboyer commented 5 years ago

Hi CY I made further tests I think there is a bug inside the gl_draw method under linux I used this work around to fix it I changed:

glDisable(GL_DEPTH_TEST); 
 gl_color(FL_GRAY); 
 char buf[32]; 
sprintf(buf, "\u03B6 = % 7.2f deg    ", _z_angle);
gl_draw(buf, -14.0f, -9.5f ); //GB
glEnable(GL_DEPTH_TEST);

with

fl_color(FL_GRAY);
fl_font(FL_HELVETICA,16);
char buf[32];
sprintf(buf, "\u03B6 = % 7.2f deg    ", _z_angle);
cout << "Debug buf: " << buf <<  "\n";
fl_draw(buf, -14, 9);

My only concern is I can't see the content of the string "buf" on the GUI but only on the terminal (it's delta = 0 deg) thank you Gio

cytan299 commented 5 years ago

Technically, both fl_draw(const char, int x, int y) and fl_draw(const char, float x, float y) are wrappers to:

fl_draw(const char, const int / length of string*/, int x, int y)

and so I'm surprised that it doesn't crash.

You might want to move the x,y position of the label to see if you see the label somewhere on the GUI.

Sorry, I don't do Linux so I can't really see what you're seeing. But I'll continue looking because I don't believe fl_draw() is the source of the crash.

cytan299 commented 5 years ago

P.S. You seem to have forgotten the minus sign in fl_draw(), i.e. fl_draw(buf, -14, 9) should be fl_draw(buf, -14, -9)

roboticboyer commented 5 years ago

1st test I tried with fl_draw(buf, -14, -9) and others X and Y coordinates but without success

please note that now I'm using fl_draw (FLTK) not yet gl_draw (openGL) Could be mixed FL functions/methods with OpenGL ones?

2nd test Again segmentation fault using:

const float xg=-14.0f;
const float yg=-9.5f;
glRasterPos2f(xg,yg); 
gl_draw(buf, strlen(buf));

Probably something related to openGL libraries

cytan299 commented 5 years ago

One more suggestion, get rid of \u03B6 in the string. See if it’s barfing because your system couldn’t find the font. This is really a long shot.

roboticboyer commented 5 years ago

I tested sprintf(buf, "Dz = % 7.2f deg ", _z_angle); but it doesn't fix the issue

I expanded the program window up to 800x800 and used: fl_draw(buf, 20, 500); but I can't see the text fl_draw(buf, -20, -500); but I can't see the text

Using cout << "Debug buf: " << buf << "\n"; I see the text on the console, so the variable buf is OK

cytan299 commented 5 years ago

I think the problem with using fl_draw() is that it will not draw to the OpenGL context. So you will need to use gl_draw() to see anything. You may be right that there is a bug in the OpenGL implementation in Linux, or Linux requires some more OpenGL initialization that is not needed in Mac OS X. At this point, I’m not sure I have anything else to add or to help you fix this Linux problem because I don’t do Linux.