[M3devel] NT386GNU status/fishing for guesses..

Olaf Wagner wagner at elegosoft.com
Sun Feb 17 10:30:01 CET 2008


Quoting Jay <jayk123 at hotmail.com>:

> 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)..

Yes, the C interfaces are the place where ports are most likely to
be broken. There are no checks there; it's completely unsafe.
I wonder if one could write a checker that compares the sizes of
the most important structures in C and M3, but that would probably
not be trivial.

> 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.

Yes, it's always a good idea to get the base right at the start.
On the other hand, you will usually return there during ant porting,
regardless of your best efforts ;-)

> 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

[Could you try to persuade your mailer to produce a readable text
  form besides HTML? If not it looks like that :-(]

Anyway, as your previous posting asked about a change in general POSIX
support files, I'd really advise you to try out such changes on at
least one other platform (e.g. Linux), however innocuous they may seem.

Thanks for all the work,

Olaf
-- 
Olaf Wagner -- elego Software Solutions GmbH
                Gustav-Meyer-Allee 25 / Gebäude 12, 13355 Berlin, Germany
phone: +49 30 23 45 86 96  mobile: +49 177 2345 869  fax: +49 30 23 45 86 95
    http://www.elegosoft.com | Geschäftsführer: Olaf Wagner | Sitz: Berlin
Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194




More information about the M3devel mailing list