shithub: riscv

Download patch

ref: 56927887249d8529afa57c38d7935edb2d9cc49f
parent: 1f464e0013ddc9b5901a50d11d4ef5bd570be39c
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu Nov 22 05:30:45 EST 2018

snap: be more conservative taking stack snapshot

include up to 8k below the stack to get some more context.

don't assume stack is at least 16K.

--- a/sys/src/cmd/snap/take.c
+++ b/sys/src/cmd/snap/take.c
@@ -20,7 +20,7 @@
 	return sum;
 }
 
-static int npage;
+static ulong npage;
 static Page *pgtab[1<<10];
 
 Page*
@@ -32,7 +32,7 @@
 	int iszero;
 
 	if(len > Pagesize) {
-		fprint(2, "datapage cannot handle pages > 1024\n");
+		fprint(2, "datapage cannot handle pages > %d\n", Pagesize);
 		exits("datapage");
 	}
 
@@ -277,14 +277,14 @@
 	if(stacklen) {
 		sp = stackptr(proc, fd);
 		if(stackoff <= sp && sp < stackoff+stacklen) {
-			off = (sp - Pagesize) & ~(Pagesize - 1);
-			if(off < stackoff)
-				off = stackoff;
-			len = stacklen - (off - stackoff);
+			off = sp - 8*1024;
 		} else {	/* stack pointer not in segment.  thread library? */
 			off = stackoff + stacklen - 16*1024;
-			len = 16*1024;
 		}
+		off &= ~((uvlong)Pagesize-1);
+		if(off < stackoff)
+			off = stackoff;
+		len = stacklen - (off - stackoff);
 		s[stacki] = readseg(fd, off, len, "Stack");
 	}