Commit 2f641044 authored by Sebastian Brzezinka's avatar Sebastian Brzezinka Committed by Tomasz Zawadzki
Browse files

llvm/vfio: Suppress checking leaks for `spdk_nvme_ctrlr_alloc_io_qpair`



LSAN has problems detecting references stored in DPDK-managed memory,
causing leak sanitizer to reports leaking memory incorrectly.

This behavior is specific to fuzzers, since
`__lsan_do_recoverable_leak_check` is called in runtime after each
`TestOneInput`, and not only at the end of the program.

Fixes issue #3258.

Change-Id: I13cc9315f0c26a0f03bb9cf6cf6f0128943f11da
Signed-off-by: default avatarSebastian Brzezinka <sebastian.brzezinka@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21897


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent 05faf8e7
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -15,7 +15,11 @@
#include "spdk/vfio_user_pci.h"
#include <linux/vfio.h>
#include "spdk/vfio_user_spec.h"
#include "spdk/config.h"

#ifdef SPDK_CONFIG_ASAN
#include <sanitizer/lsan_interface.h>
#endif
#define VFIO_MAXIMUM_SPARSE_MMAP_REGIONS	8
#define VFIO_USER_GET_REGION_INFO_LEN		4096

@@ -472,7 +476,18 @@ init_io(void *ctx)
		return NULL;
	}

	/* Even if ASan is enabled in DPDK, leak sanitizer has problems detecting
	 * references allocated in DPDK-manage memory. This causes LSAN to report
	 * a false memory leak when the 'pqpair->stat' variable is allocated on
	 * the heap, but the only reference is stored on `qpair` that is DPDK-manage
	 * making it not visible for LSAN. */
#ifdef SPDK_CONFIG_ASAN
	__lsan_disable();
#endif
	g_io_thread.io_qpair = spdk_nvme_ctrlr_alloc_io_qpair(g_io_thread.io_ctrlr, NULL, 0);
#ifdef SPDK_CONFIG_ASAN
	__lsan_enable();
#endif
	if (g_io_thread.io_qpair == NULL) {
		spdk_nvme_detach(g_io_thread.io_ctrlr);
		fprintf(stderr, "spdk_nvme_ctrlr_alloc_io_qpair failed\n");