crash on destroy_display in OSX 10.9
sleepywind

On Mac OSX 10.9 everytime when Factorio (www.factorio.com) 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): http://www.factorioforums.com/forum/viewtopic.php?f=7&t=1714 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:

#SelectExpand
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

#SelectExpand
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

General recommendation for destroy ordering is FILO - first in last out. So destroy things in the reverse order you initialized them.

Peter Wang

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.

Thread #613627. Printed from Allegro.cc