summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
87c6f22)
Since it can happen that memory allocated with smalloc() is freed by
a child process and since Valgrind's memory tracking is per process
the smalloc()/sfree() instrumentation leads to incorrect Valgrind
reports. Hence remove that instrumentation again.
Fixes:
0ffccc21fcd6 ("Improve Valgrind instrumentation of memory allocations")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
#include <sys/mman.h>
#include <assert.h>
#include <string.h>
#include <sys/mman.h>
#include <assert.h>
#include <string.h>
-#ifdef CONFIG_VALGRIND_DEV
-#include <valgrind/valgrind.h>
-#else
-#define RUNNING_ON_VALGRIND 0
-#define VALGRIND_MALLOCLIKE_BLOCK(addr, size, rzB, is_zeroed) do { } while (0)
-#define VALGRIND_FREELIKE_BLOCK(addr, rzB) do { } while (0)
-#endif
#include "fio.h"
#include "fio_sem.h"
#include "fio.h"
#include "fio_sem.h"
-#ifdef SMALLOC_REDZONE
-#define REDZONE_SIZE sizeof(unsigned int)
-#else
-#define REDZONE_SIZE 0
-#endif
-
struct block_hdr {
size_t size;
#ifdef SMALLOC_REDZONE
struct block_hdr {
size_t size;
#ifdef SMALLOC_REDZONE
{
unsigned int *postred = postred_ptr(hdr);
{
unsigned int *postred = postred_ptr(hdr);
- /* Let Valgrind fill the red zones. */
- if (RUNNING_ON_VALGRIND)
- return;
-
hdr->prered = SMALLOC_PRE_RED;
*postred = SMALLOC_POST_RED;
}
hdr->prered = SMALLOC_PRE_RED;
*postred = SMALLOC_POST_RED;
}
{
unsigned int *postred = postred_ptr(hdr);
{
unsigned int *postred = postred_ptr(hdr);
- /* Let Valgrind check the red zones. */
- if (RUNNING_ON_VALGRIND)
- return;
-
if (hdr->prered != SMALLOC_PRE_RED) {
log_err("smalloc pre redzone destroyed!\n"
" ptr=%p, prered=%x, expected %x\n",
if (hdr->prered != SMALLOC_PRE_RED) {
log_err("smalloc pre redzone destroyed!\n"
" ptr=%p, prered=%x, expected %x\n",
- VALGRIND_FREELIKE_BLOCK(ptr, REDZONE_SIZE);
sfree_pool(pool, ptr);
return;
}
sfree_pool(pool, ptr);
return;
}
-static void *__smalloc(size_t size, bool is_zeroed)
+void *smalloc(size_t size)
{
unsigned int i, end_pool;
{
unsigned int i, end_pool;
if (ptr) {
last_pool = i;
if (ptr) {
last_pool = i;
- VALGRIND_MALLOCLIKE_BLOCK(ptr, size,
- REDZONE_SIZE,
- is_zeroed);
-void *smalloc(size_t size)
-{
- return __smalloc(size, false);
-}
-
void *scalloc(size_t nmemb, size_t size)
{
void *scalloc(size_t nmemb, size_t size)
{
- return __smalloc(nmemb * size, true);
+ return smalloc(nmemb * size);
}
char *smalloc_strdup(const char *str)
}
char *smalloc_strdup(const char *str)