forked from enlightenment/efl
Eo: Prevent shutdown from actually doing anything
Currently, eo_shutdown can't work. Every Eo_Class ID is stored inside its class_get() function as a static variable. This means any call to class_get() after eo_shutdown() (even if eo_init was done properly) will lead to using an invalid ref for the class id. In other words, the class is not valid anymore, and objects can't be created. Resetting the pointer to NULL would be possible, if we passed it during the class creation. But this would lead to potential crashes if a class was created from a now dlclosed library. The only solution I can envision here is to check that class_get actually returns a valid ref with the right class name. Most likely the performance impact is not acceptable. This fixes make check for me (with systemd module for ecore).
This commit is contained in:
parent
0dd9e02df2
commit
e47edc250d
|
@ -1849,10 +1849,21 @@ eo_shutdown(void)
|
|||
{
|
||||
size_t i;
|
||||
_Eo_Class **cls_itr = _eo_classes;
|
||||
const char *s;
|
||||
|
||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(_eo_init_count > 0, EINA_FALSE);
|
||||
if (--_eo_init_count > 0)
|
||||
return EINA_TRUE;
|
||||
|
||||
/* We can't actually shutdown Eo for similar reasons that closing a
|
||||
* shared library is risky: all Eo_Class IDs are stored inside their
|
||||
* classname_get() function and can't be safely reset to NULL. */
|
||||
if (!(s = getenv("EO_SHUTDOWN_ENABLE")) || (atoi(s) != 1))
|
||||
{
|
||||
_eo_init_count = 1;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
eina_log_timing(_eo_log_dom,
|
||||
EINA_LOG_STATE_START,
|
||||
EINA_LOG_STATE_SHUTDOWN);
|
||||
|
@ -1872,7 +1883,10 @@ eo_shutdown(void)
|
|||
eina_spinlock_free(&_eo_class_creation_lock);
|
||||
|
||||
if (_eo_call_stack_key != 0)
|
||||
eina_tls_free(_eo_call_stack_key);
|
||||
{
|
||||
eina_tls_free(_eo_call_stack_key);
|
||||
_eo_call_stack_key = 0;
|
||||
}
|
||||
|
||||
_eo_free_ids_tables();
|
||||
|
||||
|
|
Loading…
Reference in New Issue