shithub: riscv

Download patch

ref: e4436ec0bbb6e525addbe2f4a250c1de69247828
parent: 4f3724e6e1cdc5a43714efd56888b2cde38c497b
author: cinap_lenrek <[email protected]>
date: Tue Jul 15 16:45:00 EDT 2014

page: fix deadlock with addpage (thanks BurnZeZ for the stacktraces)

addpage() should not be called with the display locked as it
calls showpage1() which sleeps when there are too many
processes active.

the bug was triggered by plumbing to trigger the addpage().

--- a/sys/src/cmd/page.c
+++ b/sys/src/cmd/page.c
@@ -1681,7 +1681,6 @@
 	ground = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x777777FF);
 	display->locking = 1;
 	unlockdisplay(display);
-	drawlock(1);
 
 	einit(Ekeyboard|Emouse);
 	eplumb(Eplumb, "image");
@@ -1698,6 +1697,7 @@
 	for(; *argv; argv++)
 		addpage(root, *argv, popenfile, strdup(*argv), -1);
 
+	drawlock(1);
 	for(;;){
 		drawlock(0);
 		i=event(&e);
@@ -1802,7 +1802,9 @@
 				j = trywalk(s, plumblookup(pm->attr, "addr"));
 				if(j == nil){
 					current = root;
+					drawlock(0);
 					j = addpage(root, s, popenfile, s, fd);
+					drawlock(1);
 				}
 				showpage(j);
 			}