- Fix lock debug code for gcc sanitizer reports.

This commit is contained in:
W.C.A. Wijngaards 2021-09-10 15:11:30 +02:00
parent 7d70e3c861
commit a64cbe958d
7 changed files with 38 additions and 4 deletions

View file

@ -210,7 +210,6 @@ daemon_init(void)
} }
#endif /* USE_WINSOCK */ #endif /* USE_WINSOCK */
signal_handling_record(); signal_handling_record();
checklock_start();
#ifdef HAVE_SSL #ifdef HAVE_SSL
# ifdef HAVE_ERR_LOAD_CRYPTO_STRINGS # ifdef HAVE_ERR_LOAD_CRYPTO_STRINGS
ERR_load_crypto_strings(); ERR_load_crypto_strings();

View file

@ -781,6 +781,7 @@ main(int argc, char* argv[])
int cmdline_cfg = 0; int cmdline_cfg = 0;
#endif #endif
checklock_start();
log_init(NULL, 0, NULL); log_init(NULL, 0, NULL);
log_ident_default = strrchr(argv[0],'/')?strrchr(argv[0],'/')+1:argv[0]; log_ident_default = strrchr(argv[0],'/')?strrchr(argv[0],'/')+1:argv[0];
log_ident_set_default(log_ident_default); log_ident_set_default(log_ident_default);

View file

@ -1264,9 +1264,9 @@ int main(int argc, char** argv)
memset(&tls_list, 0, sizeof(tls_list)); memset(&tls_list, 0, sizeof(tls_list));
/* lock debug start (if any) */ /* lock debug start (if any) */
checklock_start();
log_ident_set("unbound-dnstap-socket"); log_ident_set("unbound-dnstap-socket");
log_init(0, 0, 0); log_init(0, 0, 0);
checklock_start();
#ifdef SIGPIPE #ifdef SIGPIPE
if(signal(SIGPIPE, SIG_IGN) == SIG_ERR) { if(signal(SIGPIPE, SIG_IGN) == SIG_ERR) {

View file

@ -1,5 +1,6 @@
10 September 2021: Wouter 10 September 2021: Wouter
- Fix initialisation errors reported by gcc sanitizer. - Fix initialisation errors reported by gcc sanitizer.
- Fix lock debug code for gcc sanitizer reports.
8 September 2021: Wouter 8 September 2021: Wouter
- Merged #41 from Moritz Schneider: made outbound-msg-retry - Merged #41 from Moritz Schneider: made outbound-msg-retry

View file

@ -909,9 +909,9 @@ int main(int argc, char* argv[])
const char* f; const char* f;
const char* opt = NULL; const char* opt = NULL;
const char* cfgfile = CONFIGFILE; const char* cfgfile = CONFIGFILE;
checklock_start();
log_ident_set("unbound-checkconf"); log_ident_set("unbound-checkconf");
log_init(NULL, 0, NULL); log_init(NULL, 0, NULL);
checklock_start();
#ifdef USE_WINSOCK #ifdef USE_WINSOCK
/* use registry config file in preference to compiletime location */ /* use registry config file in preference to compiletime location */
if(!(cfgfile=w_lookup_reg_str("Software\\Unbound", "ConfigFile"))) if(!(cfgfile=w_lookup_reg_str("Software\\Unbound", "ConfigFile")))

View file

@ -944,9 +944,9 @@ int main(int argc, char* argv[])
extern int check_locking_order; extern int check_locking_order;
check_locking_order = 0; check_locking_order = 0;
#endif /* USE_THREAD_DEBUG */ #endif /* USE_THREAD_DEBUG */
checklock_start();
log_ident_set("unbound-control"); log_ident_set("unbound-control");
log_init(NULL, 0, NULL); log_init(NULL, 0, NULL);
checklock_start();
#ifdef USE_WINSOCK #ifdef USE_WINSOCK
/* use registry config file in preference to compiletime location */ /* use registry config file in preference to compiletime location */
if(!(cfgfile=w_lookup_reg_str("Software\\Unbound", "ConfigFile"))) if(!(cfgfile=w_lookup_reg_str("Software\\Unbound", "ConfigFile")))

View file

@ -387,6 +387,37 @@ static void check_order(rbtree_type* all_locks)
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
/** delete lock ref */
static void dellockref(rbnode_type* node, void* ATTR_UNUSED(arg))
{
struct lock_ref* o = (struct lock_ref*)node;
if(!o) return;
free(o->file);
free(o);
}
/** delete lock node */
static void delnode(rbnode_type* node, void* ATTR_UNUSED(arg))
{
struct order_lock* o = (struct order_lock*)node;
if(!o) return;
free(o->create_file);
if(o->smaller) {
traverse_postorder(o->smaller, &dellockref, NULL);
free(o->smaller);
}
free(o);
}
/** delete allocated memory */
static void locks_free(rbtree_type* all_locks)
{
if(!all_locks)
return;
traverse_postorder(all_locks, &delnode, NULL);
free(all_locks);
}
/** main program to verify all traces passed */ /** main program to verify all traces passed */
int int
main(int argc, char* argv[]) main(int argc, char* argv[])
@ -403,6 +434,7 @@ main(int argc, char* argv[])
usage(); usage();
return 1; return 1;
} }
checklock_start();
log_init(NULL, 0, NULL); log_init(NULL, 0, NULL);
log_ident_set("lock-verify"); log_ident_set("lock-verify");
/* init */ /* init */
@ -421,6 +453,7 @@ main(int argc, char* argv[])
printf("checked %d locks in %d seconds with %d errors.\n", printf("checked %d locks in %d seconds with %d errors.\n",
(int)all_locks->count, (int)(time(NULL)-starttime), (int)all_locks->count, (int)(time(NULL)-starttime),
errors_detected); errors_detected);
locks_free(all_locks);
if(errors_detected) return 1; if(errors_detected) return 1;
return 0; return 0;
} }