[master] b9dc76c Try to force remapping to different addresses to expose bugs about that.

Poul-Henning Kamp phk at FreeBSD.org
Mon Jun 12 16:35:10 CEST 2017


commit b9dc76cfdfaa7d336a6a84c1db80a3523256ab7a
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jun 12 14:33:09 2017 +0000

    Try to force remapping to different addresses to expose bugs about that.

diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c
index ad03d0c..425e0f7 100644
--- a/lib/libvarnishapi/vsm.c
+++ b/lib/libvarnishapi/vsm.c
@@ -240,6 +240,8 @@ VSM_Delete(struct vsm *vd)
 
 /*--------------------------------------------------------------------*/
 
+static void *ppp;
+
 int
 VSM_Open(struct vsm *vd)
 {
@@ -291,13 +293,21 @@ VSM_Open(struct vsm *vd)
 		    vd->iname));
 	}
 
-	v = mmap(NULL, slh.shm_size,
+	v = mmap(ppp, slh.shm_size,
 	    PROT_READ, MAP_SHARED|MAP_HASSEMAPHORE, vd->vsm_fd, 0);
+	if (v == MAP_FAILED)
+		v = mmap(NULL, slh.shm_size,
+		    PROT_READ, MAP_SHARED|MAP_HASSEMAPHORE, vd->vsm_fd, 0);
 	if (v == MAP_FAILED) {
 		closefd(&vd->vsm_fd);
 		return (vsm_diag(vd, "Cannot mmap %s: %s",
 		    vd->iname, strerror(errno)));
 	}
+	/*
+	 * Force failure of client depends on remapping at same address. 
+	 */
+	ppp = (char*)v + getpagesize() * 1000;
+
 	vd->head = v;
 	vd->b = v;
 	vd->e = vd->b + slh.shm_size;



More information about the varnish-commit mailing list