detect crashes at startup or early and enable "safe mode" so if you hit

restart e will not load modules - maybe safe mode should also restore default
theme and other things too later...


SVN revision: 24321
This commit is contained in:
Carsten Haitzler 2006-07-30 19:34:05 +00:00
parent cbaad3914a
commit bcce7b2397
4 changed files with 70 additions and 25 deletions

View File

@ -49,9 +49,11 @@ main(int argc, char **argv)
int i;
int nostartup = 0;
int after_restart = 0;
int safe_mode = 0;
char buf[PATH_MAX];
char *s;
struct sigaction action;
double t, tstart;
/* trap deadly bug signals and allow some form of sane recovery */
/* or ability to gdb attach and debug at this point - better than your */
/* wm/desktop vanishing and not knowing what happened */
@ -92,6 +94,22 @@ main(int argc, char **argv)
sigemptyset(&action.sa_mask);
sigaction(SIGABRT, &action, NULL);
t = ecore_time_get();
s = getenv("START_TIME");
if ((s) && (getenv("CRASHED")))
{
tstart = atof(s);
if ((t - tstart) < 5.0)
{
safe_mode = 1;
}
}
e_util_env_set("CRASHED", NULL);
tstart = t;
snprintf(buf, sizeof(buf), "%1.1f", tstart);
e_util_env_set("START_TIME", buf);
/* FIXME: this is the init code for letting e be relocatable. right now
* its not used - so i want to see if it can reliably determine its exe
* prefix
@ -296,7 +314,7 @@ main(int argc, char **argv)
"Perhaps you are out of memory?"));
_e_main_shutdown(-1);
}
if(!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP, _e_main_cb_signal_hup, NULL))
if (!ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP, _e_main_cb_signal_hup, NULL))
{
e_error_message_show(_("Enlightenment cannot set up a HUP signal handler.\n"
"Perhaps you are out of memory?"));
@ -314,7 +332,7 @@ main(int argc, char **argv)
_e_main_shutdown(-1);
}
_e_main_shutdown_push(_e_main_x_shutdown);
/* init x */
/* init white box of death alert */
if (!e_alert_init(NULL))
{
e_error_message_show(_("Enlightenment cannot initialize its emergency alert system.\n"
@ -374,6 +392,7 @@ main(int argc, char **argv)
"Ecore and check they support the Software Buffer rendering engine."));
_e_main_shutdown(-1);
}
{
Ecore_Evas *ee;
Evas_Object *im;
@ -599,6 +618,21 @@ main(int argc, char **argv)
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_color_class_shutdown);
/* load modules */
if (!safe_mode)
e_module_all_load();
else
{
e_int_config_modules(e_container_current_get(e_manager_current_get()));
e_error_message_show
(_("Enlightenment crashed early on start and has<br>"
"been restarted. All modules have been disabled<br>"
"and will not be loaded to help remove any problem<br>"
"modules from your configuration. The module<br>"
"configuration dialog should let you select your<br>"
"modules again."));
e_config_save_queue();
}
/* setup gadcon */
if (!e_gadcon_init())
{

View File

@ -34,6 +34,33 @@ static Evas_List *_e_modules = NULL;
/* externally accessible functions */
EAPI int
e_module_init(void)
{
return 1;
}
EAPI int
e_module_shutdown(void)
{
Evas_List *l, *tmp;
#ifdef HAVE_VALGRIND
/* do a leak check now before we dlclose() all those plugins, cause
* that means we won't get a decent backtrace to leaks in there
*/
VALGRIND_DO_LEAK_CHECK
#endif
for (l = _e_modules; l;)
{
tmp = l;
l = l->next;
e_object_del(E_OBJECT(tmp->data));
}
return 1;
}
EAPI void
e_module_all_load(void)
{
Evas_List *pl = NULL, *l;
@ -59,29 +86,6 @@ e_module_init(void)
e_config_save_queue();
}
}
return 1;
}
EAPI int
e_module_shutdown(void)
{
Evas_List *l, *tmp;
#ifdef HAVE_VALGRIND
/* do a leak check now before we dlclose() all those plugins, cause
* that means we won't get a decent backtrace to leaks in there
*/
VALGRIND_DO_LEAK_CHECK
#endif
for (l = _e_modules; l;)
{
tmp = l;
l = l->next;
e_object_del(E_OBJECT(tmp->data));
}
return 1;
}
EAPI E_Module *

View File

@ -48,6 +48,7 @@ struct _E_Module_Api
EAPI int e_module_init(void);
EAPI int e_module_shutdown(void);
EAPI void e_module_all_load(void);
EAPI E_Module *e_module_new(const char *name);
EAPI int e_module_save(E_Module *m);
EAPI const char *e_module_dir_get(E_Module *m);

View File

@ -25,6 +25,7 @@ e_sigseg_act(int x, siginfo_t *info, void *data)
ecore_x_keyboard_ungrab();
ecore_x_ungrab();
ecore_x_sync();
e_util_env_set("CRASHED", "SEGV");
e_alert_show("This is very bad. Enlightenment has segfaulted.\n"
"This is not meant to happen and is likely a sign of a\n"
"bug in Enlightenment or the libraries it relies on.\n"
@ -50,6 +51,7 @@ e_sigseg_act(int x, siginfo_t *info, void *data)
ecore_x_keyboard_ungrab();
ecore_x_ungrab();
ecore_x_sync();
e_util_env_set("CRASHED", "SEGV");
e_alert_show("This is very bad. Enlightenment has segfaulted.\n"
"This is not meant to happen and is likely a sign of a\n"
"bug in Enlightenment or the libraries it relies on.\n"
@ -76,6 +78,7 @@ e_sigill_act(int x, siginfo_t *info, void *data)
ecore_x_keyboard_ungrab();
ecore_x_ungrab();
ecore_x_sync();
e_util_env_set("CRASHED", "ILL");
e_alert_show("This is very bad. Enlightenment has executed and illegal\n"
"instruction. This is most likely because Enlightenment or\n"
"a library it depends on has been compiled for a CPU type\n"
@ -102,6 +105,7 @@ e_sigfpe_act(int x, siginfo_t *info, void *data)
ecore_x_keyboard_ungrab();
ecore_x_ungrab();
ecore_x_sync();
e_util_env_set("CRASHED", "FPE");
e_alert_show("This is very bad. Enlightenment has recieved a floating\n"
"point exception. This is probably due to a divide by 0\n"
"in Enlightenment or a library it depends on.\n"
@ -127,6 +131,7 @@ e_sigbus_act(int x, siginfo_t *info, void *data)
ecore_x_keyboard_ungrab();
ecore_x_ungrab();
ecore_x_sync();
e_util_env_set("CRASHED", "BUS");
e_alert_show("This is very bad. Enlightenment has recieved a bus error.\n"
"This could be for many reasons - accessing memory not in\n"
"its available address space or unable to be paged in.\n"
@ -152,6 +157,7 @@ e_sigabrt_act(int x, siginfo_t *info, void *data)
ecore_x_keyboard_ungrab();
ecore_x_ungrab();
ecore_x_sync();
e_util_env_set("CRASHED", "ABRT");
e_alert_show("This is very bad. Enlightenment has recieved an abort.\n"
"This could be for many reasons - accessing memory not in\n"
"its available address space or unable to be paged in.\n"