[gccsdk] Threading + Alt-Break = Trashed Computer

John Tytgat John.Tytgat at aaug.net
Fri Jul 11 08:39:54 PDT 2008


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

> On Thu, 10 Jul 2008, John-Mark Bell wrote:
> > Therefore, it seems obvious that the filters need removing by UnixLib  
> > when Alt-Break happens. Quite how we achieve this is left as an exercise  
> > for the reader -- my knowledge of the watchdog is approximately nil.
> 
> 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 which finalizes several aspects in
UnixLib whom the whole pthread ticker system.  Basically the framework is
there and is working when the user code bluntly calls SWI OS_Exit (which
Adam tried).  So I'm getting more and more curious on the fact what makes
that this does not seem to work for the watchdog.

For those who what to eyeball the UnixLib source: exit handler is '__h_exit'
(signal/_signal.s) which after setting up a private stack, calls the well
known C 'exit' (unix/unix.c).  The latter will call atexit() registered
callbacks and ends up calling the also well known C _Exit() implementation.

That one finalizes all C streams and calls the internal _exit routine
which finalizes more UnixLib aspects involving calling __pthread_stop_ticker
(pthread/_context.s).  There we stop the ticker and deregister the Pre and
Post Wimp filter.

I'm not in the position to debug this right now but I can only guess that
either __pthread_stop_ticker is not called (because somehow we think it
shouldn't be called), or not effectively doing something either as we no
longer think we're running a Wimp task, or... that
Filter_DeRegisterPreFilter/Filter_DeRegisterPostFilter is not working as
maybe the task is no longer known to the Wimp (so the filter hook stays
active until its taskhandle matches the one of a new task launched).
Note, these are very wild guesses.

> Slightly hackier, you could do so on the pre-poll filter of the
> Wimp_Poll call made by the Wimp's default exit handler (which will be called
> when any user-installed exit handler exits itself by calling OS_Exit).

I don't think that behaviour is documented, is it ?

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