Axel Rose has noted (SourceForge) that MacPerl crashes under certain 
conditions if the script is stopped by Menu->StopScript or the 
key-board equivalent. I can confirm this behaviour.

The condition is hard to define but involves a script of the general form:

        $d = HTTP::Daemon();

        while (1) {
                $connection = $d->accept;
                if ($connection) {
                        ....
                        do stuff
                        ....
                }

                $connection->close;
        }

I have not been able to contrive a simple script which demonstrates 
the problem. However with the complex and length script concerned 
(not mine I hasten to add) MacPerl crashes every time on closing with 
'StopScript'.

The MacsBugs report is attached, and again is exactly the same for 
every crash. So the culprit without question is GUSITimer::Kill(). 
What is far from clear to me is how or why GUSITime::Kill() gets 
involved, or, for that matter, what actually happens when 
Menu->StopScript is hit.

This much is clear: fmStopScrip sets gAborting to 'true'. OK, that 
sounds reasonable.

Now the fun starts: gAborting occurs seven times in 'macperl' as follows.

1) MPAppleEvents.c";    Line 264:       gAborting = true;
2) MPConsole.cp";       Line 625:       if (gAborting && gRunningPerl) {
3) MPConsole.cp";       Line 630:       gAborting = false;
4) MPFile.c";           Line 193:       gAborting = true;
5) MPGlobals.h";        Line 300:       EXTERN Boolean    gAborting;
6) MPMain.c";           Line 648:       gAborting = true;
7) MPScript.c";         Line 647:       gAborting = false;

Number 1 occurs in 'DoStopScript()' which is called by AppleEvents. OK.

Number 2 is more complicated and occurs in MPConsoleSpin() which is 
the procedure for:

        GUSISetHook(Gusi_SpinHook, (GUSIHook)MPConsoleSpin);

So far as I can determine GUSISetHook is called only once in 
'InitConsole' -- all other instances have been commented out. I can 
find no reason to suppose it (or MPConsoleSpin() for that matter) 
gets called in response to a 'Menu->StopScript' hit. Does anybody 
agree or disagree?

Number 3 occurs also in MPConsoleSpin(), the first few lines of which read:

        if (gAborting && gRunningPerl) {
                ResetConsole();

                raise(SIGINT);
                // don't raise SIGINT again
                gAborting = false;
        }

So -- let us suppose by some mechanism yet to be explained 
MPConsoleSpin() DOES get called. What happens in ResetConsole()? 
Well, it is:

        for (DPtr doc = gConsoleList; doc; doc = doc->u.cons.next)
                if (doc->u.cons.selected)
                        doc->u.cons.selected = false;

        gWantConsoleInput       = false;
        ShowWindowStatus();

all of which looks reasonable but none of which seems to be involved 
in any way with the SpinCursor.

Number 4 occurs in DoQuit() and as such sheds no further light on the matter.

Number 5 is in the header file which we can ignore here.

Number 6 is where gAborting is set by fmStopScript (i.e. where we started).

Number 7 occurs in CleanUpPerl(), which sheds no light on the proceedings.


So the questions that occurs to me are firstly: 'How is StopScript 
supposed to work?' and secondly 'How or why does GUSITime::Kill() get 
called?'

The matter is of this importance. The script which causes the crash 
works fine on Windows and Linux and (I believe) on Mac OSX. On those 
three platforms it also enjoys nice GUIs. On the Classic Mac it just 
crashes and no-one can get a GUI to work with it anyway.

That's rather a pity, and I would like to try to help 'mend the 
nuisance' (as Peyps put it in his diary when his neighbour 
inadvertently filled up his cellar with sewage). I believe Axel feels 
much the same way.

Alan Fry

--------

  Disassembling PowerPC code from 168CCD38
   GUSITimer::Kill()
      +00024 168CCD38   bl         RmvTime                    ; 
0x168FE048 | 48031311
      +00028 168CCD3C   lwz        RTOC,0x0014(SP) 
| 80410014
      +0002C 168CCD40   lwz        r4,0x001A(r31) 
| 809F001A
      +00030 168CCD44   b          GUSITimer::Kill()+0004C    ; 
0x168CCD60 | 4800001C
      +00034 168CCD48   cmplw      r3,r31 
| 7C03F840
      +00038 168CCD4C   bne        GUSITimer::Kill()+00048    ; 
0x168CCD5C | 40820010
      +0003C 168CCD50   lwz        r0,0x001E(r31) 
| 801F001E
      +00040 168CCD54   stw        r0,0x0000(r4) 
| 90040000
      +00044 168CCD58   b          GUSITimer::Kill()+00058    ; 
0x168CCD6C | 48000014
      +00048 168CCD5C   addi       r4,r3,0x001E 
| 3883001E
      +0004C 168CCD60  *lwz        r3,0x0000(r4) 
| 80640000
      +00050 168CCD64   cmplwi     r3,0x0000 
| 28030000
      +00054 168CCD68   bne        GUSITimer::Kill()+00034    ; 
0x168CCD48 | 4082FFE0
      +00058 168CCD6C   li         r0,0x0000 
| 38000000
      +0005C 168CCD70   stw        r0,0x001E(r31) 
| 901F001E
      +00060 168CCD74   stw        r0,0x001A(r31) 
| 901F001A
      +00064 168CCD78   lwz        r0,0x0048(SP) 
| 80010048
      +00068 168CCD7C   addi       SP,SP,0x0040 
| 38210040
      +0006C 168CCD80   lwz        r31,-0x0004(SP) 
| 83E1FFFC
      +00070 168CCD84   mtlr       r0                         ; LR = 
0x0008 | 7C0803A6

Reply via email to