[M3devel] NT386GNU status/fishing for guesses..

Jay jayk123 at hotmail.com
Sun Feb 17 09:47:52 CET 2008


Nevermind, of course, I should have known, even though I'm working on fixing the stat struct (probably to blame for files always being out of date) and thought I might have it right, I should have known, I have it too small and the next variable is getting overwritten, causing us to close(0)..
If I put in arbitrary large padding at the end, it grows enough to cover up the problem..now to get it right..
null_fd and the entire struct stat need not be globals, just the dev field...of course optimize that and I would have a stack corruption instead, not sure it would have been harder or easier to figure out..I should have started at the bottom of the system and gotten all the headers right in the first place....sigh.
 
VAR  null_done := FALSE;  null_stat: Ustat.struct_stat;  null_fd: INTEGER;
 
PROCEDURE IsDevNull(READONLY statbuf: Ustat.struct_stat): BOOLEAN RAISES {} =  VAR result: INTEGER;  BEGIN    IF NOT null_done THEN      null_done := TRUE;      null_fd := Unix.open(        M3toC.FlatTtoS("/dev/null"), Unix.O_RDONLY, Unix.Mrwrwrw);      IF null_fd < 0 THEN RETURN FALSE END;      RTIO.PutText("1 null_fd is " & Fmt.Int(null_fd) & "\n");   3      result := Ustat.fstat(null_fd, ADR(null_stat));      RTIO.PutText("2 null_fd is " & Fmt.Int(null_fd) & "\n");    0      EVAL Unix.close(null_fd);        and then close 0 here oops      IF result # 0 THEN null_fd := -1 END


From: jayk123 at hotmail.comTo: m3devel at elegosoft.comSubject: RE: [M3devel] NT386GNU status/fishing for guesses..Date: Sat, 16 Feb 2008 19:37:46 +0000


Ok, is this reasonable for all platforms? Otherwise I can push into Unix.m3. ===================================================================RCS file: /usr/cvs/cm3/m3-libs/libm3/src/os/POSIX/ProcessPosix.m3,vretrieving revision 1.6diff -u -r1.6 ProcessPosix.m3--- ProcessPosix.m3     29 Nov 2007 05:05:56 -0000      1.6+++ ProcessPosix.m3     16 Feb 2008 19:36:08 -0000@@ -266,6 +266,9 @@   (* Make file descriptor "fd" refer to file "h", or set "fd"'s      close-on-exec flag if "h=NoFile".  Return "TRUE" if succesful. *)   BEGIN+    IF fd = h THEN+      RETURN TRUE;+    END;     IF h # NoFileDescriptor THEN       RETURN NOT Unix.dup2(h, fd) < 0     ELSIF Unix.fcntl(fd, Unix.F_SETFD, 1) >= 0 THEN - Jay


From: jayk123 at hotmail.comTo: m3devel at elegosoft.comDate: Sat, 16 Feb 2008 19:30:01 +0000Subject: [M3devel] NT386GNU status/fishing for guesses..

PROCEDURE ExecChild(    argx: ArrCStr; (* see "AllocArgs" for layout *)    envp: Ctypes.char_star_star;    wdstr: Ctypes.char_star;    stdin, stdout, stderr: INTEGER) : INTEGER  RAISES {} =(* Modify Unix state using "stdin", ..., and invoke execve using   "argx" and "envp".  Do not invoke scheduler, allocator, or   exceptions.  Return only if a fatal Unix error is encountered, in   which case Cerrno.GetErrno() is set. *)  VAR res := 0; t: Ctypes.char_star;  BEGIN    IF wdstr # NIL THEN      IF Unix.chdir(wdstr) < 0 THEN RETURN -1; END    END;(*    IF NOT (SetFd(0, stdin) AND SetFd(1, stdout) AND SetFd(2, stderr)) THEN      RETURN -1;    END;    FOR fd := 3 TO Unix.getdtablesize() - 1 DO      EVAL Unix.close(fd) (* ignore errors *)    END;*)Without those lines commented out, only ever one file gets compiled.The process create for the second cm3cg fails (but not for the first as).Nearby code uses 99 for the exit code. With these commented out, it proceeds to compile everything (at least in one directory). Some combinations of the one block vs. the other (I realize there's only four cominations total) go and compile everything but claim failure at the end. Different point is that subsequent runs of cm3 always recompile everything.Probably the timestamps are misunderstood. I need to check the stat structure. Any one have any wild guesses on the process create angle?I figured this out with strace.The SetFd calls lead to dup failing because 0 isn't open. The Cygwin code is all very gnarly.For example when you do vfork + exec, it seems to relaunch the current .executable first (with kernel32.dll CreateProcess) and then child executables -- running cm3cg+as on just one file takes six CreateProcess calls -- cm3, sh, cm3cg, cm3, sh, as. I wonder if "Services for Unix" would satisfy folks at least as well as Cygwin. It is a free (beer) download..  - Jay

Need to know the score, the latest news, or you need your Hotmail®-get your "fix". Check it out. 

Connect and share in new ways with Windows Live. Get it now! 
_________________________________________________________________
Need to know the score, the latest news, or you need your Hotmail®-get your "fix".
http://www.msnmobilefix.com/Default.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20080217/9b632d0f/attachment-0002.html>


More information about the M3devel mailing list