Skip to content
Snippets Groups Projects
Commit a03568f9 authored by Tomas Krizek's avatar Tomas Krizek
Browse files

Merge branch 'strict-aliasing' into 'master'

fix strict aliasing problems

See merge request !962
parents eecc029c cad90154
Branches
Tags
1 merge request!962fix strict aliasing problems
Pipeline #61476 passed with warnings with stages
in 1 hour and 37 seconds
......@@ -9,6 +9,7 @@ Bugfixes
--------
- cache: missing filesystem support for pre-allocation is no longer fatal (#549)
- lua: policy.rpz() no longer watches the file when watch is set to false (!954)
- fix a strict aliasing problem that might've lead to "miscompilation" (!962)
Knot Resolver 5.0.1 (2020-02-05)
......
......@@ -64,7 +64,7 @@ static inline size_t array_next_count(size_t want)
}
/** @internal Incremental memory reservation */
static inline int array_std_reserve(void *baton, char **mem, size_t elm_size, size_t want, size_t *have)
static inline int array_std_reserve(void *baton, void **mem, size_t elm_size, size_t want, size_t *have)
{
if (*have >= want) {
return 0;
......@@ -110,7 +110,7 @@ static inline void array_std_free(void *baton, void *p)
* Mempool usage: pass kr_memreserve and a knot_mm_t* .
* @return 0 if success, <0 on failure */
#define array_reserve_mm(array, n, reserve, baton) \
(reserve)((baton), (char **) &(array).at, sizeof((array).at[0]), (n), &(array).cap)
(reserve)((baton), (void **) &(array).at, sizeof((array).at[0]), (n), &(array).cap)
/**
* Push value at the end of the array, resize it if necessary.
......
......@@ -46,7 +46,7 @@ static void test_array(void **state)
}
/** Reservation through tracked memory allocator. */
static int test_reserve(void *baton, char **mem, size_t elm_size, size_t want, size_t *have)
static int test_reserve(void *baton, void **mem, size_t elm_size, size_t want, size_t *have)
{
if (want > *have) {
void *new_mem = mm_alloc(baton, elm_size * want);
......@@ -62,7 +62,7 @@ static int test_reserve(void *baton, char **mem, size_t elm_size, size_t want, s
}
/** Reservation through fake memory allocator. */
static int fake_reserve(void *baton, char **mem, size_t elm_size, size_t want, size_t *have)
static int fake_reserve(void *baton, void **mem, size_t elm_size, size_t want, size_t *have)
{
return -1;
}
......
......@@ -213,7 +213,7 @@ char* kr_strcatdup(unsigned n, ...)
return result;
}
int kr_memreserve(void *baton, char **mem, size_t elm_size, size_t want, size_t *have)
int kr_memreserve(void *baton, void **mem, size_t elm_size, size_t want, size_t *have)
{
if (*have >= want) {
return 0;
......
......@@ -261,7 +261,7 @@ static inline bool kr_rand_coin(unsigned int nomin, unsigned int denomin)
/** Memory reservation routine for knot_mm_t */
KR_EXPORT
int kr_memreserve(void *baton, char **mem, size_t elm_size, size_t want, size_t *have);
int kr_memreserve(void *baton, void **mem, size_t elm_size, size_t want, size_t *have);
/** @internal Fast packet reset. */
KR_EXPORT
......
......@@ -118,6 +118,14 @@ add_project_arguments(
'-Werror=implicit-function-declaration', # Probably messed up includes; implicit functions are evil!
'-fvisibility=hidden',
'-DHAVE_ASPRINTF=' + have_asprintf.to_int().to_string(),
# libuv handles have aliasing problems; see:
# https://github.com/libuv/libuv/pull/2588/files#diff-04c6e90faac2675aa89e2176d2eec7d8
# https://github.com/libuv/libuv/issues/1230#issuecomment-569030944
# Performance impact in our case seems OK:
# https://gitlab.labs.nic.cz/knot/knot-resolver/-/merge_requests/962#note_147407
'-fno-strict-aliasing',
language: 'c',
)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment