Commit cbcdce99 authored by Alexander Sosedkin's avatar Alexander Sosedkin
Browse files

lib/str: condition realloc on AGGRESSIVE_REALLOC


Signed-off-by: Alexander Sosedkin's avatarAlexander Sosedkin <asosedkin@redhat.com>
parent c9c64e1d
Pipeline #267858131 passed with stages
in 106 minutes and 46 seconds
......@@ -389,6 +389,33 @@ fedora-valgrind/test:
only:
- branches@gnutls/gnutls
fedora-valgrind-aggressive/build:
extends:
- .build
- .fedora
script:
- ./bootstrap
# gcc in fedora31 inlines strcmp in a way that causes valgrind errors
- CFLAGS="-O2 -g -fno-builtin-strcmp -DAGGRESSIVE_REALLOC" ./configure --disable-gcc-warnings --disable-doc --cache-file $CCACHE_FILE --disable-guile --disable-full-test-suite --enable-valgrind-tests
- make -j$BUILDJOBS
- make -j$BUILDJOBS check TESTS=""
only:
- branches@gnutls/gnutls
fedora-valgrind-aggressive/test:
extends:
- .test
- .fedora
script:
- GNUTLS_TEST_TIMEOUT=600000 make -j$(nproc) check
dependencies:
- fedora-valgrind-aggressive/build
needs:
- fedora-valgrind-aggressive/build
timeout: 5h
only:
- branches@gnutls/gnutls
fedora-threadsan/build:
extends:
- .build
......
......@@ -146,24 +146,23 @@ int _gnutls_buffer_resize(gnutls_buffer_st * dest, size_t new_size)
if (unlikely(dest->data != NULL && dest->allocd == NULL))
return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
/* When running under valgrind, use a simpler logic for reallocation;
/* Use a simpler logic for reallocation;
* i.e., always call gnutls_realloc_fast() and do not reclaim the
* no-longer-used area which has been removed from the beginning of
* buffer with _gnutls_buffer_pop_datum().
* This helps hit more issues when running under valgrind.
*/
#ifdef HAVE_VALGRIND_MEMCHECK_H
if (RUNNING_ON_VALGRIND) {
size_t unused = MEMSUB(dest->data, dest->allocd);
dest->allocd =
gnutls_realloc_fast(dest->allocd, new_size);
if (dest->allocd == NULL) {
gnutls_assert();
return GNUTLS_E_MEMORY_ERROR;
}
dest->max_length = new_size;
dest->data = dest->allocd + unused;
return 0;
#ifdef AGGRESSIVE_REALLOC
size_t unused = MEMSUB(dest->data, dest->allocd);
dest->allocd =
gnutls_realloc_fast(dest->allocd, new_size);
if (dest->allocd == NULL) {
gnutls_assert();
return GNUTLS_E_MEMORY_ERROR;
}
dest->max_length = new_size;
dest->data = dest->allocd + unused;
return 0;
#endif
if (dest->max_length >= new_size) {
......
Markdown is supported
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