applications generate errors and crash clients with freeglut

Message boards : API : applications generate errors and crash clients with freeglut
Message board moderation

To post messages, you must log in.

AuthorMessage
m.somers

Send message
Joined: 31 Jan 06
Posts: 4
Netherlands
Message 3039 - Posted: 12 Feb 2006, 17:57:30 UTC

Hi,

I've noticed that applications, graphical ones, that use freeglut, on linux specifically, generate huge amounts of error messages. If, through the boinc manager, a graphical view is closed en re-opened, error messages to stderr are produced. They end up in the stderr.txt file on the host of the client, filling up the disk and eventually put the system to a halt. Not nice for a host doing work for you ;-)

The reason that this happens is because in the API a bug is present in the x_opengl.C file. It was unnoticed probably because with the original glut library, no error messages are produced because of the 'bad-glutting'.

I have restructured the x_opengl.C code and got rid of that nasty bug. Now when a graphical view is closed, and reopened, you actually do get a new view and not millions of error messages. Moreover, the code now works correctly with both the original glut library and the freeglut library.

Here is the patch (created with diff) on the 5.3 version of 10-06-2005:

--- boinc/api/x_opengl.C 2005-09-06 14:58:55.000000000 +0200
+++ Boinc_2005-10-06_source_fixes.dir/api/x_opengl.C 2006-02-12 18:36:14.071839352 +0100
@@ -17,6 +17,15 @@
// or write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

+// M.F.Somers UPDATE:
+//
+// Removed an anoying bug when using GLUT. Apparently the glutMainloop
+// and the glutDestoryWindow routines are being kept called as soon as a user
+// hits the x button of the window, but glutInit isn't recalled... After
+// having removed the bug, also made the code a bit easier to understand...
+
+// #define _DEBUG
+
#include <stdlib.h>
#include <stdio.h>
#include <setjmp.h>
@@ -138,106 +147,67 @@
}
}

-void CloseWindow() {
- set_mode(MODE_HIDE_GRAPHICS);
-}
-
-static void make_new_window(int mode) {
- if ( (mode != MODE_WINDOW) && (mode != MODE_FULLSCREEN) ) {
- // nothing to be done here
- return;
- }
-
- if (!glut_is_initialized) {
- boinc_glut_init();
- }
+static void boinc_glut_init( void ) {
+ const char* args[2] = {"screensaver", NULL};
+ int one=1;
+
+ app_debug_msg("Called patched boinc_glut_init()... \\n");
+
+ if( glut_is_initialized ) return;
+
+ glutInit (&one, (char**)args);
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
+ glutInitWindowPosition(xpos, ypos);
+ glutInitWindowSize(600, 400);

- app_debug_msg("make_new_window(): now calling glutCreateWindow(%s)...\\n", aid.app_name);
win = glutCreateWindow(aid.app_name);
- app_debug_msg("glutCreateWindow() succeeded. win = %d\\n", win);
-
- // installing callbacks for the current window
glutReshapeFunc(app_graphics_resize);
glutKeyboardFunc(keyboardD);
glutKeyboardUpFunc(keyboardU);
glutMouseFunc(mouse_click);
glutMotionFunc(mouse_click_move);
glutDisplayFunc(maybe_render);
+
glEnable(GL_DEPTH_TEST);
+
#ifdef __APPLE__
- glutWMCloseFunc(CloseWindow); // Enable the window's close box
BringAppToFront();
#endif
- app_graphics_init();

- if (mode == MODE_FULLSCREEN) {
- glutFullScreen();
- }
+ app_graphics_init();
+
+ glut_is_initialized = true;

return;
}

-// initialized glut and screensaver-graphics
-// this should only called once, even if restarted by user-exit
-//
-static void boinc_glut_init() {
- const char* args[2] = {"screensaver", NULL};
- int one=1;
- app_debug_msg("Calling glutInit()... \\n");
- glutInit (&one, (char**)args);
- app_debug_msg("...survived glutInit(). \\n");
-
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
- glutInitWindowPosition(xpos, ypos);
- glutInitWindowSize(600, 400);
- g_bmsp->boinc_get_init_data_hook(aid);
- if (!strlen(aid.app_name)) {
- strcpy(aid.app_name, "BOINC Application");
- }
-
- glut_is_initialized = true;

- return;
+// M.F.Somers UPDATE: this has been simplified...
+void set_mode(int mode) {

-}
+ app_debug_msg("Called patched set_mode(%d): current_mode = %d.\\n", mode, current_graphics_mode);

-// Destroy current window if any
-//
-void KillWindow() {
- if (win) {
- int oldwin = win;
- win = 0; // set this to 0 FIRST to avoid recursion if the following call fails.
- glutDestroyWindow(oldwin);
- }
-}
+ if (!glut_is_initialized) boinc_glut_init();

-void set_mode(int mode) {
- if (mode == current_graphics_mode) {
#ifdef __APPLE__
- // Bring graphics window to front whenever user presses "Show graphics"
- if (mode == MODE_WINDOW)
- BringAppToFront();
+ if (mode == MODE_WINDOW)
+ BringAppToFront();
+#else
+ if (mode == MODE_WINDOW)
+ glutShowWindow();
#endif
- return;
- }
-
- app_debug_msg("set_mode(%d): current_mode = %d.\\n", mode, current_graphics_mode);
- if (glut_is_initialized) {
- app_debug_msg("Calling KillWindow(): win = %d\\n", win);
- KillWindow();
- app_debug_msg("...KillWindow() survived.\\n");
- }
-
- if (mode != MODE_HIDE_GRAPHICS) {
- app_debug_msg("set_mode(): Calling make_new_window(%d)\\n", mode);
- make_new_window(mode);
- app_debug_msg("...make_new_window() survived.\\n");
- }
+
#ifdef __APPLE__
- else
+ if (mode == MODE_HIDE_GRAPHICS)
HideThisApp();
+#else
+ if (mode == MODE_HIDE_GRAPHICS)
+ glutHideWindow();
#endif

+ if (mode == MODE_FULLSCREEN)
+ glutFullScreen();
+
current_graphics_mode = mode;

return;
@@ -278,7 +248,7 @@
case MODE_HIDE_GRAPHICS:
case MODE_WINDOW:
case MODE_FULLSCREEN:
- case MODE_BLANKSCREEN:
+ case MODE_BLANKSCREEN:if( current_graphics_mode == MODE_HIDE_GRAPHICS )
if (strlen(m.display)) {
sprintf(buf, "DISPLAY=%s", m.display);
putenv(buf);
@@ -403,6 +373,11 @@
// handle glut's notorious exits()..
atexit(restart);

+ g_bmsp->boinc_get_init_data_hook(aid);
+ if (!strlen(aid.app_name)) {
+ strcpy(aid.app_name, "BOINC Application");
+ }
+
// THIS IS THE re-entry point at exit or ABORT in the graphics-thread
restarted = setjmp(jbuf);

@@ -415,6 +390,12 @@
}
}

+// M.F.Somers UPDATE: there the fix is for the anoying bug... however, the code
+// has been restructured so it also works with freeglut...
+ glut_is_initialized = false;
+ win = 0;
+ current_graphics_mode = MODE_HIDE_GRAPHICS;
+
if (boinc_is_standalone()) {
if (restarted) {
while(1) {
@@ -425,30 +406,27 @@
set_mode(MODE_WINDOW);
glutTimerFunc(TIMER_INTERVAL_MSEC, timer_handler, 0);
}
- } else {
- if (!glut_is_initialized) {
+
+ app_debug_msg ("Running standalone, now calling glutMainLoop()...\\n");
+ glutMainLoop();
+ app_debug_msg ("glutMainLoop() returned...\\n");
+ return;
+ }
+
#ifdef __APPLE__
- setMacPList();
+ setMacPList();
#endif
- set_mode(MODE_HIDE_GRAPHICS);
- while ( current_graphics_mode == MODE_HIDE_GRAPHICS ) {
- app_debug_msg ("Graphics-thread now waiting for client-message...\\n");
- wait_for_initial_message();
- app_debug_msg ("got a graphics-message from client... \\n");
- timer_handler(0);
- }
- } else
- // here glut has been initialized previously
- // probably the user pressed window-'close'
- //
- set_mode(MODE_HIDE_GRAPHICS); // close any previously open windows
- }

- // ok we should be ready & initialized by now to call glutMainLoop()
- //
- app_debug_msg ("now calling glutMainLoop()...\\n");
- glutMainLoop();
- app_debug_msg("...glutMainLoop() returned!! This should never happen...\\n");
+ while( 1 )
+ {
+ app_debug_msg ("Graphics-thread now waiting for client-message...\\n");
+ wait_for_initial_message();
+ timer_handler(0);
+ app_debug_msg ("Graphics-thread now running glutMainLoop()...\\n");
+ glutMainLoop();
+ app_debug_msg ("Graphics-thread glutMainLoop() returned...\\n");
+ }
+
}

#ifndef _DEBUG


Cheers,

mark somers.


mark somers
mail: m.somers@chem.leidenuniv.nl
web: http://rulgla.leidenuniv.nl/Researchers/Somers.htm
ID: 3039 · Report as offensive
slap happy gas pedal

Send message
Joined: 18 Apr 06
Posts: 3
United States
Message 3963 - Posted: 18 Apr 2006, 23:12:57 UTC
Last modified: 18 Apr 2006, 23:15:08 UTC

Just FYI to show what a pain this is...

The stderr.txt on my BOINC setup reached upwards of 16 Gb.
So i deleted it, and as usual the WimpXP system said that it had to delete it immediately sine it was too big, and of course as feared, it didnt actually delete the file...
The 'stderr.txt' file disappeared so i cant find it anymore, but it didnt free up any space whatsoever. Its caught in some limbo-land juat an invisible squatter taking up valuable space (my system down to less than a gig) and cant be freed by any amount of repeated reboots, 'chkdsk /F' runs, defragmenting, or searching through invisible system files to find it anywhere...

...so its another complete reinstall of WinXP for me (once again).
ID: 3963 · Report as offensive
Pepo
Avatar

Send message
Joined: 3 Apr 06
Posts: 547
Slovakia
Message 3994 - Posted: 20 Apr 2006, 12:26:51 UTC - in response to Message 3963.  

Just FYI to show what a pain this is...

The stderr.txt on my BOINC setup reached upwards of 16 Gb.
So i deleted it, and as usual the WimpXP system said that it had to delete it immediately sine it was too big, and of course as feared, it didnt actually delete the file...
The 'stderr.txt' file disappeared so i cant find it anymore, but it didnt free up any space whatsoever. Its caught in some limbo-land juat an invisible squatter taking up valuable space (my system down to less than a gig) and cant be freed by any amount of repeated reboots, 'chkdsk /F' runs, defragmenting, or searching through invisible system files to find it anywhere...

...so its another complete reinstall of WinXP for me (once again).

You can try Sysinternals' DiskView utility whether it will show up there. You'll sure not miss such large file even if hidden in some limbo-land and/or wildly renamed by the system.

Peter
ID: 3994 · Report as offensive

Message boards : API : applications generate errors and crash clients with freeglut

Copyright © 2021 University of California. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.