Branch: Tag:

2016-07-25

2016-07-25 15:31:12 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Runtime: Detect cyclic calls of load_module().

With a high debug- or trace-level, id_to_program() sometimes
triggered infinite cyclic loading of some modules due to programs
not having received their permanent program ids yet.

22:   # include "constants.h"   # include "lex.h"   # include "object.h" + # include "cyclic.h"      #else /* TESTING */   
441:   {    extern int global_callable_flags;    -  void *module; +  void *module = NULL;    modfun init, exit;    struct module_list *new_module;    struct pike_string *module_name;       ONERROR err; -  +  DECLARE_CYCLIC();       module_name = Pike_sp[-args].u.string;   
466:    }    }    +  if (!BEGIN_CYCLIC(module_name, 0)) { +  SET_CYCLIC_RET(1); +     /* Removing RTLD_GLOBAL breaks some PiGTK themes - Hubbe */    /* Using RTLD_LAZY is faster, but makes it impossible to    * detect linking problems at runtime..    */    module=dlopen(module_name->str,    RTLD_NOW /*|RTLD_GLOBAL*/ ); -  +  }       if(!module)    {
604:    dynamic_module_list = new_module->next;    free_string(new_module->name);    free(new_module); +  END_CYCLIC();    Pike_error("Failed to initialize dynamic module \"%S\".\n",    module_name);    }    } -  +  END_CYCLIC();   }      #endif /* USE_DYNAMIC_MODULES */