From: Alan T. DeKok Date: Wed, 31 Jan 2024 14:06:31 +0000 (-0500) Subject: delay reading dictionaries until after setting up debug state X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8f6766106fd5b2235be103b5a93e2f2216dacf4;p=thirdparty%2Ffreeradius-server.git delay reading dictionaries until after setting up debug state On Linux, fr_get_debug_state() calls fork() to get debugging status. It then calls exit(), which calls the atexit() handlers, which complain that memory isn't cleaned up. We hoist those checks to above the "read dictionary" call, so that the atexit() handlers won't trigger. --- diff --git a/src/lib/server/main_config.c b/src/lib/server/main_config.c index 1fcfb35aa1d..5805a3cfc4a 100644 --- a/src/lib/server/main_config.c +++ b/src/lib/server/main_config.c @@ -1074,6 +1074,28 @@ int main_config_init(main_config_t *config) */ config->talloc_pool_size = 8 * 1024; /* default */ + cs = cf_section_alloc(NULL, NULL, "main", NULL); + if (!cs) return -1; + + /* + * Add a 'feature' subsection off the main config + * We check if it's defined first, as the user may + * have defined their own feature flags, or want + * to manually override the ones set by modules + * or the server. + */ + subcs = cf_section_find(cs, "feature", NULL); + if (!subcs) { + subcs = cf_section_alloc(cs, cs, "feature", NULL); + if (!subcs) { + failure: + fr_dict_free(&config->dict, __FILE__); + talloc_free(cs); + return -1; + } + } + dependency_features_init(subcs); + if (fr_dict_internal_afrom_file(&config->dict, FR_DICTIONARY_INTERNAL_DIR, __FILE__) < 0) { PERROR("Failed reading internal dictionaries"); goto failure; @@ -1098,9 +1120,6 @@ do {\ */ DICT_READ_OPTIONAL(config->raddb_dir, FR_DICTIONARY_FILE); - cs = cf_section_alloc(NULL, NULL, "main", NULL); - if (!cs) return -1; - /* * Special-case things. If the output is a TTY, AND * we're debugging, colourise things. This flag also @@ -1114,24 +1133,6 @@ do {\ } default_log.line_number = config->log_line_number; - /* - * Add a 'feature' subsection off the main config - * We check if it's defined first, as the user may - * have defined their own feature flags, or want - * to manually override the ones set by modules - * or the server. - */ - subcs = cf_section_find(cs, "feature", NULL); - if (!subcs) { - subcs = cf_section_alloc(cs, cs, "feature", NULL); - if (!subcs) { - failure: - talloc_free(cs); - return -1; - } - } - dependency_features_init(subcs); - /* * Add a 'version' subsection off the main config * We check if it's defined first, this is for