- Online Community Forums » Programming Questions » crash on destroy_display in OSX 10.9

This thread is locked; no one can reply to it. rss feed Print
crash on destroy_display in OSX 10.9
Member #14,665
October 2012

On Mac OSX 10.9 everytime when Factorio ( tries to destroy the display there comes the crash. This is only issue on that specific OS, it works fine on lower OSX versions as well as Win and Linux. The stacktrace can be found here (on the game forum): From the stack trace it looks like some sound routines are still running when destroying the display.

I am probably missing something in the destroy sequence. The destroy sequence was done mostly by trial and error mechanism:-[, so I suppose there can be plenty wrong. Here is the relevant code of the destroy sequence:

1Display::~Display() 2{ 3 al_destroy_font(this->font); 4 this->font = NULL; 5 al_destroy_font(this->itemCountFont); 6 this->itemCountFont = NULL; 7 delete this->itemCountFontAgui; 8 this->itemCountFontAgui = NULL; 9 delete this->infiniteFontAgui; 10 this->infiniteFontAgui = NULL; 11 al_destroy_bitmap(this->windowIcon); 12 this->windowIcon = NULL; 13 al_shutdown_font_addon(); 14 al_shutdown_ttf_addon(); 15 al_shutdown_primitives_addon(); 16 al_shutdown_image_addon(); 17 al_uninstall_audio(); 18 al_destroy_display(this->display); 19 al_uninstall_system(); 20}

and here is the relevant part from the resources allocation

1 this->display = al_create_display(width, height); 2 3 if (!this->display) 4 throw std::runtime_error("failed to create display!"); 5 if (!al_init_image_addon()) 6 throw std::runtime_error("Failed to initialize al_init_image_addon!"); 7 8 boost::filesystem::path windowIconPath = global->paths->graphics / "factorio-icon.png"; 9 this->windowIcon = al_load_bitmap(windowIconPath.string().c_str()); 10 if (!this->windowIcon) 11 throw std::runtime_error(ssprintf("Failed to load window icon! Loading from: %s", windowIconPath.string().c_str())); 12 al_set_display_icon(this->display, this->windowIcon); 13 al_set_window_title(this->display, ssprintf("Factorio %s", ApplicationVersion::currentVersion.str().c_str()).c_str()); 14 if (!al_install_keyboard()) 15 throw std::runtime_error("failed to initialize the keyboard!"); 16 if (!al_install_mouse()) 17 throw std::runtime_error("failed to initialize the mouse!"); 18 al_init_font_addon(); 19 if (!al_init_ttf_addon()) 20 throw std::runtime_error("failed to initialize the ttf addon!"); 21 if (!al_init_primitives_addon()) 22 throw std::runtime_error("failed to load primitives addon!"); 23 if (!al_install_audio()) 24 throw std::runtime_error("Failed to install audio!"); 25 if (!al_init_acodec_addon()) 26 throw std::runtime_error("Failed to initialize audio codecs!"); 27 if (!al_reserve_samples(50)) 28 throw std::runtime_error("Failed to reserve samples!"); 29 this->loadAllegroFonts(); 30}

I played around with the OSX 10.9 machine for like an hour (I don't own one), but couldn't figure out what the problem was. I would appreciate any hints or ideas.

Edgar Reynaldo
Major Reynaldo
May 2007

Peter Wang
Member #23
April 2000

Since you shut down Allegro in a destructor you might want to ensure that the destructor is really only run when appropriate.

It could well be a bug in Allegro (if so, please fix). You might try not shutting down the addons individually and letting al_uninstall_system take care of it. al_uninstall_system is not strictly necessary either.

Go to: