Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Nov 1999 21:07:34 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        John Hay <jhay@mikom.csir.co.za>
Cc:        current@FreeBSD.ORG
Subject:   Re: doscmd broken on current? fixed
Message-ID:  <Pine.BSF.4.10.9911081902440.7289-100000@alphplex.bde.org>
In-Reply-To: <199911071935.VAA60044@zibbi.mikom.csir.co.za>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 7 Nov 1999, John Hay wrote:

> Ok, with these patches doscmd is working for me again. I can boot dos and
> run the topspeed C compiler like I used to a few months ago.
> 
> If nobody has any complaints I'll commit it. I'm just not 100% sure about
> the patch to doscmd.c and would like if someone with more knowledge about
> the signal stuff would just look at it. There is just too many signal

> Index: doscmd.c
> ===================================================================
> RCS file: /home/ncvs/src/usr.bin/doscmd/doscmd.c,v
> retrieving revision 1.11
> diff -u -r1.11 doscmd.c
> --- doscmd.c	1999/10/13 23:48:35	1.11
> +++ doscmd.c	1999/11/07 12:50:06
> @@ -258,6 +258,7 @@
>  
>      sigemptyset(&uc.uc_sigmask);
>      sigaltstack(NULL, &uc.uc_stack);
> +    uc.uc_mcontext.mc_onstack = uc.uc_stack.ss_flags;
>  
>      if (tmode)
>  	tracetrap(REGS);
> 

I only know this well enough to use the source quickly.

Setting the onstack flag to the stack flags is logically wrong because
the onstack flag is a single bit (1 or SS_ONSTACK; see (*)), while the
stack flags are some combination of SS_DISABLE and SS_ONSTACK (see
sigaltstack(2)).  The following would be logically correct:

+    uc.uc_mcontext.mc_onstack = uc.uc_stack.ss_flags & SS_ONSTACK;

but since the alternative signal stack is not in use at this point,
the rvalue is known to be 0 and the fix can be reduced to:

+    uc.uc_mcontext.mc_onstack = 0;

as in RELENG_3.  RELENG_3 also omits the sigaltstack() call (which
gives the current (almost known) alt stack settings).  I think this
is valid because uc_stack and mc_onstack are read-only for signal
handlers (any changes to uc_stack will be ignored on sigreturn(),
and any changes to mc_onstack will make a mess).  When sigreturn()
is called with a made-up context as in doscmd:main(), mc_onstack
needs to be initialised to avoid making a mess.

(*) In RELENG_3, the SS_ONSTACK bit in ss_flags is passed to signal
    handlers as "sc_onstack = ss_flags & SS_ONSTACK" but assumed to
    be returned via sigreturn() as "sc_onstack & 01".  Since
    signal handlers are not expected to modify sc_onstack, this only
    works if SS_ONSTACK = 1, as it is.

    In -current, the SS_ONSTACK bit in ss_flags is passed to signal
    handlers as "mc_onstack = ss_flags & SS_ONSTACK ? 1 : 0", so the
    old handling of the flag in sigreturn() is now logically correct,
    but this is broken since it changes the semantics for setting
    mc_onstack.

Related problems:
The USE_VM86 case in doscmd.c is more broken than in RELENG_3.  It
is missing sc -> uc name changes.

Unrelated problems:
Your patch for cwd.c helps, but lookup of /dosD/bin/ls.exe is still
broken.  The path gets converted to //dosd/bin/ls.exe.  The // is
wrong and the /dosd is broken, since that part of the path is in ffs
which is case-sensitive.

Bruce



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.10.9911081902440.7289-100000>