From 2866fe7049df652f89f3bfc1cc85ad65b3a150f8 Mon Sep 17 00:00:00 2001
From: Brian Demsky <bdemsky@uci.edu>
Date: Wed, 30 May 2012 00:18:44 -0700
Subject: [PATCH] fix bug...this is another evil one...

---
 snapshot.cc | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/snapshot.cc b/snapshot.cc
index 7cea7d6..e8fdadb 100644
--- a/snapshot.cc
+++ b/snapshot.cc
@@ -141,6 +141,15 @@ void initSnapShotLibrary(unsigned int numbackingpages,
 	}
 	initSnapShotRecord(numbackingpages, numsnapshots, nummemoryregions);
 
+	// EVIL HACK: We need to make sure that calls into the HandlePF method don't cause dynamic links
+	// The problem is that we end up protecting state in the dynamic linker...
+	// Solution is to call our signal handler before we start protecting stuff...
+
+	siginfo_t si;
+	si.si_addr=ss.ss_sp;
+	HandlePF(SIGSEGV, &si, NULL);
+	snapshotrecord->lastBackingPage--; //remove the fake page we copied
+
 	basemySpace=MYMALLOC((numheappages+1)*PAGESIZE);
 	void * pagealignedbase=PageAlignAddressUpward(basemySpace);
 	mySpace = create_mspace_with_base(pagealignedbase,  numheappages*PAGESIZE, 1 );
-- 
2.34.1