0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

Fixed crash if logging happened in unit tests

The patch initializes logging in unit tests. Previously, unit tests did
not initialize logging and other subsystems, just resources. But
resource_init() could under certain circumstances trigger logging and
cause crash.

The bug was Found by Jakub Ruzicka, dissected by David Petera and Maria
Matejka, disguised as failing build for Debian arm64 in pbuilder
emulation which did not like disabling THP.

Fixes #42.
This commit is contained in:
Ondrej Zajicek 2024-11-27 04:15:16 +01:00
parent 997d2f578e
commit fc2b4b26a6

View File

@ -59,6 +59,9 @@ u64 bt_random_state[] = {
0x53d9772877c1b647, 0xab8ce3eb466de6c5, 0xad02844c8a8e865f, 0xe8cc78080295065d 0x53d9772877c1b647, 0xab8ce3eb466de6c5, 0xad02844c8a8e865f, 0xe8cc78080295065d
}; };
void log_init_debug(char *);
void log_switch(int initial, list *l, const char *);
void void
bt_init(int argc, char *argv[]) bt_init(int argc, char *argv[])
{ {
@ -120,6 +123,10 @@ bt_init(int argc, char *argv[])
clock_gettime(CLOCK_MONOTONIC, &bt_begin); clock_gettime(CLOCK_MONOTONIC, &bt_begin);
bt_suite_case_begin = bt_suite_begin = bt_begin; bt_suite_case_begin = bt_suite_begin = bt_begin;
/* Initialize logging to stderr */
log_init_debug("");
log_switch(1, NULL, NULL);
resource_init(); resource_init();
ev_init_list(&global_event_list); ev_init_list(&global_event_list);