Skip to content

Commit

Permalink
run asan odyssey_test (#743)
Browse files Browse the repository at this point in the history
* sources/machine.c: restore loop free

Signed-off-by: rkhapov <[email protected]>

* sources/address: add destroy function

To fix memory leak in hba rule

Signed-off-by: rkhapov <[email protected]>

* run_test: run asan odyssey_test

To help find bugs in unit-tests

Signed-off-by: rkhapov <[email protected]>

---------

Signed-off-by: rkhapov <[email protected]>
Co-authored-by: rkhapov <[email protected]>
  • Loading branch information
rkhapov and rkhapov authored Dec 16, 2024
1 parent 806856e commit e8ef351
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ build_asan: clean

copy_asan_bin:
cp $(BUILD_TEST_ASAN_DIR)/sources/odyssey ./docker/bin/odyssey-asan
cp $(BUILD_TEST_ASAN_DIR)/test/odyssey_test ./docker/bin/odyssey_test_asan

build_release: clean
mkdir -p $(BUILD_REL_DIR)
Expand Down
4 changes: 4 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ set -ex

cd /test_dir/test && /usr/bin/odyssey_test

echo 0 > /proc/sys/kernel/randomize_va_space
/usr/bin/odyssey_test_asan
echo 2 > /proc/sys/kernel/randomize_va_space

setup

# group
Expand Down
6 changes: 6 additions & 0 deletions sources/address.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <odyssey.h>
#include <regex.h>
#include <arpa/inet.h>
#include "address.h"

/*
* Odyssey.
Expand All @@ -17,6 +18,11 @@ od_address_range_t od_address_range_create_default()
return address_range;
}

void od_address_range_destroy(od_address_range_t *range)
{
free(range->string_value);
}

void od_address_range_copy(od_address_range_t *src, od_address_range_t *dst)
{
dst->string_value = strndup(src->string_value, src->string_value_len);
Expand Down
2 changes: 2 additions & 0 deletions sources/address.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ struct od_address_range {

od_address_range_t od_address_range_create_default();

void od_address_range_destroy(od_address_range_t *range);

void od_address_range_copy(od_address_range_t *, od_address_range_t *);

int od_address_range_read_prefix(od_address_range_t *, char *);
Expand Down
1 change: 1 addition & 0 deletions sources/hba_rule.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void od_hba_rule_free(od_hba_rule_t *hba)
free(item->value);
free(item);
}
od_address_range_destroy(&hba->address_range);
free(hba);
}

Expand Down
2 changes: 1 addition & 1 deletion third_party/machinarium/sources/machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static inline void machine_free(mm_machine_t *machine)
mm_coroutine_cache_free(&machine->coroutine_cache);
mm_eventmgr_free(&machine->event_mgr, &machine->loop);
mm_signalmgr_free(&machine->signal_mgr, &machine->loop);
// mm_loop_shutdown(&machine->loop);
mm_loop_shutdown(&machine->loop);
mm_scheduler_free(&machine->scheduler);
}

Expand Down

0 comments on commit e8ef351

Please sign in to comment.