<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
User threads is apparently sufficient to let it work -- no change to sbrk vs. mmap.<BR>
You end up with a wierd mix of shared and not shared data, right?<BR>
I'll try to make it use pthreads and Modula-3 threads and not fork().<BR>
 <BR>
 - Jay<BR><BR> <BR>
<HR id=stopSpelling>
From: jay.krell@cornell.edu<BR>To: hosking@cs.purdue.edu<BR>Date: Tue, 16 Mar 2010 16:10:15 +0000<BR>CC: m3devel@elegosoft.com<BR>Subject: Re: [M3devel] cvsup<BR><BR>
<STYLE>
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Verdana;}
</STYLE>
I could have sworn I had not seen hanging with sbrk or map_shared, but I can't get that now.<BR>I'll dig a bit more..maybe not today.<BR>To be clear, this isn't even the usual fork+exec. This is fork + do work + exit.<BR>We can probably fix it by having it create a Modula-3 thread.<BR>   The first fork (daemonize) is probably fine. It is the per-client one that I think is a problem.<BR>I'd like to find a theory as to why it ever worked, maybe see it work, and then fix it differently.<BR>  Maybe sbrk + user threads?<BR> <BR>(Can anyone claim to have seen cvsup server work with kernel threads?)<BR> <BR> - Jay<BR> <BR>
<HR id=ecxstopSpelling>
From: hosking@cs.purdue.edu<BR>Date: Tue, 16 Mar 2010 11:43:52 -0400<BR>To: jay.krell@cornell.edu<BR>CC: m3devel@elegosoft.com<BR>Subject: Re: [M3devel] cvsup<BR><BR><BASE>mmap is strongly preferred over sbrk. 
<DIV><BR></DIV>
<DIV>I'd need to understand the control flow here in and across the processes, but yes, generally, mixing pthreads with fork may require significant care.</DIV>
<DIV><BR>
<DIV>
<DIV>On 16 Mar 2010, at 11:33, Jay K wrote:</DIV><BR class=ecxecxApple-interchange-newline>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxecxApple-style-span>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxecxhmmessage>Daniel thank you for the bug report.<BR>Thank you for suggesting strace. I used strace<BR>and compared working vs. non-working.<BR>And started added RTIO everywhere.<BR>You can also use cvsup -f to slightly simplify -- one fork instead of two.<BR>gdb set follow mode didn't seem to help.<BR> <BR> <BR>I almost have it nailed down.<BR> <BR> <BR>in CVSup, FSServer.m3, this code:<BR> <BR>FINALLY<BR>    IF isChild THEN<BR>        SigHandler.ShutDown(); <==<SPAN class=ecxecxApple-converted-space> </SPAN><BR>    ELSE<BR>        SigHandler.Unblock();<BR>    END;<BR>END;<BR><BR> <BR>which runs fairly early, never returns in the child.<BR> <BR> <BR>It ends up here:<BR> <BR> <BR>PROCEDURE ChangeState(d: Dispatcher; state: State) =<BR>  (* Ask the dispatcher thread to change to a new state, and wait until<BR>     it has made the change. *)<BR>  BEGIN<BR>    LOCK d.mu DO<BR>      d.desiredState := state;<BR>      IF d.state # d.desiredState THEN<BR>        IF d.state = State.Running THEN<BR>          (* Send dummy signal 0 to wake up the dispatcher. *)<BR>          Catch(0);<BR>        ELSE<BR>          Thread.Signal(d.changeState);<BR>        END;<BR>        WHILE d.state # d.desiredState DO<BR>          Thread.Wait(d.mu, d.stateChanged);   <== this never returns<BR>        END;<BR>      END;<BR>    END;<BR>  END ChangeState;<BR> <BR> <BR>It's a bit wierd to be mixing fork() and Modula-3 Thread?<BR>Or maybe it is ok?<BR> <BR> <BR>See, they are asking another process, from the fork() point of view, to change the state.<BR>  It does so, but the write is private.<BR> <BR> <BR>Remember...Olaf changed from sbrk to mmap(anon|private) in RTOS.GetMemory()?<BR>  sbrk is maybe shared? mmap(anon|private) is not.<BR> <BR>Right now I have<BR>#ifndef apple<BR>sbrk<BR>#else<BR>mmap(anon|shared)<BR>#endif<BR> <BR> <BR>and it gets further.<BR>Hit an assertion failure in pthread.<BR>I'll try again.<BR>Cleanup all my RTIO.<BR> <BR> <BR>Maybe this notion of using fork() is just not supportable?<BR> <BR> <BR>In either case...you could paint it as an m3core problem, but<BR>?it won't affect much code?.<BR> <BR> <BR> - Jay<BR> <BR>
<HR id=ecxecxstopSpelling>
From:<SPAN class=ecxecxApple-converted-space> </SPAN><A href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</A><BR>To:<SPAN class=ecxecxApple-converted-space> </SPAN><A href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</A><BR>Subject: cvsup<BR>Date: Tue, 16 Mar 2010 12:32:49 +0000<BR><BR>I can reproduce the cvsup problem.<BR>An important point to consider is that cvsupd forks a server?<BR> Maybe that messes up initialization?<BR> I'll dig further.<BR> <BR> <BR>I think these steps are complete.<BR>I'll test them on a second clean system.<BR>You don't need any real data.<BR> <BR> <BR><A href="mailto:jay@xlin2:~$">jay@xlin2:~$</A><SPAN class=ecxecxApple-converted-space> </SPAN>cat cvsupd.cfg<BR>*default tag=.<BR>*default host=xlin2.<BR>*default prefix=/home/jay<BR>*default base=/home/jay/var/db<BR>*default release=cvs delete use-rel-suffix compress<BR> <BR>src-all<BR> <BR> <BR>mkdir -p $HOME/var/db<BR>mkdir -p $HOME/data/cvsupd<BR>pkill cvsupd # cleanup any previous<BR> <BR> <BR>You don't really need any data.<BR>cvsup/cvsupd will issue an error in the "working" case, and<BR>hang in the non-working case.<BR> <BR><BR><BR><BR>run the server:<BR> <BR> <BR><A href="mailto:jay@xlin2:~$">jay@xlin2:~$</A><SPAN class=ecxecxApple-converted-space> </SPAN>/cm3/bin/cvsupd -b $HOME/data/cvsupd<BR>2010.03.16 05:24:25 PDT [22555]: CVSup server started<BR>2010.03.16 05:24:25 PDT [22555]: Software version: 2010-03-05 10:55:15<BR>2010.03.16 05:24:25 PDT [22555]: Protocol version: 17.0<BR>2010.03.16 05:24:25 PDT [22555]: Ready to service requests<BR><BR><BR>run the client:<BR> <BR> /cm3/bin/cvsup -g -L 2 $HOME/cvsupd.cfg<BR> <BR> <BR>Parsing supfile "/home/jay/cvsupd.cfg"<BR>Connecting to xlin2.<BR>Connected to xlin2.<BR>Server software version: 2010-03-05<BR>Negotiating file attribute support<BR>Exchanging collection information<BR>Server message: Unknown collection "src-all"<BR>Establishing multiplexed-mode data connection<BR>Running<BR>Skipping collection src-all/cvs<BR>Shutting down connection to server<BR>Finished successfully<BR> <BR>it is able to talk to the server, and then fails.<BR>Ok -- at least it talked to the server.<BR> <BR>The server then exits too.<BR>I think that is correct (read the usage on the -C option).<BR> <BR> <BR>Then try with -C.<BR>The bug says -C 2. Let's use -C 1.<BR>They behave the same for our purposes.<BR> <BR> <BR>Just add -C 1 to the above server.<BR>Run the same client.<BR>The client hangs -- it never connects to the server.<BR> <BR> <BR>I reproduced this on LINUXLIBC6 and PPC_LINUX.<BR>Maybe more soon.<BR>I'm just rebuilding first.<BR> <BR> <BR> - Jay<BR></DIV></SPAN></BLOCKQUOTE></DIV><BR></DIV>                                     </body>
</html>