[gccsdk] Threading + Alt-Break = Trashed Computer

John Tytgat John.Tytgat at aaug.net
Sat Jul 12 09:14:39 PDT 2008


In message <op.ud5cm4w8l0n5eg at balaptop.ba>
          "Ben Avison" <bavison at riscosopen.org> wrote:

> John Tytgat <John.Tytgat at aaug.net> wrote:
> > In message <op.ud3ma5pfl0n5eg at balaptop.ba>
> >           "Ben Avison" <bavison at riscosopen.org> wrote:
> >> The watchdog sets a transient callback from the key event, and in the
> >> callback it does a task switch (without going through Wimp_Poll) and  
> >> calls SWI OS_Exit.
> >>
> >> The neatest thing you could do would be to install an exit handler to  
> >> remove the filters.
> >
> > Actually UnixLib has an exit handler [...]
> 
> You know what, I think this looks like a Wimp bug. The fact that the Watchdog
> was doing a primitive task switch and then calling OS_Exit had me wondering
> about how come the correct exit handler was called - the answer seems to be
> it isn't. As a quick test, I used the following BASIC program:
> 
>   10 SYS "OS_ChangeEnvironment",11,&10000000
>   20 REPEAT UNTIL FALSE
> 
> Run the program, do Alt-Break, kill the task itself (task "Unknown"), result
> is prefetch abort at &10000004, as expected. Now try again, this time click
> "Next task" to select another task, kill that instead, result is a stiffed
> machine. This indicates that the environment isn't being switched and the
> Wimp is doing a poor job of recovering from the error.
> 
> Presumably in the UnixLib case, the task that was running when the Break
> key event goes off only has the default Wimp exit handler installed. This
> wouldn't directly cause an abort, but it would have the effect that the
> UnixLib exit handler is bypassed and so its filters don't get removed.
> 
> If this is as true as it appears, I'm amazed such a fundamental bug in the
> Watchdog has gone unnoticed as long as it has!

I can confirm that for the cases Adam's test program was not the current
task when pressing <Alt><Break>, system instability occured because of a
pending filter hook as mentioned before.  And this because that in those
cases UnixLib's exit handler was not called by the Wimp.

Actually Wimp's Watchdog.s in ROOL's codebase is pretty clear : in
watchdogcallback you have around line 209 the test whether the current
task needs to die or not.  In case of the former a more or less straight
OS_Exit is done and that's the case which works as expected.

In the other case, the chosen task is delinked from the Wimp's internals
and that's it.  This means the chosen task's exit handler does not get
called (and I don't think the environment is left in a sane state either).
I'm wondering why we don't have after the 'pageintask' call a SWI OS_Exit
call as well.

John.
-- 
John Tytgat, in his comfy chair at home                                 BASS
John.Tytgat at aaug.net                             ARM powered, RISC OS driven




More information about the gcc mailing list