mikeoro@hubcap.clemson.edu (Michael K O'Rourke) (07/06/89)
Well, I got a multitude of responses on my last question. All saying the same thing - remove the RememberA0() in the Receive function. Thank you for your help. I did remove the statement. However, it still crashes my machine. As I said before, the machine crashes a few seconds after the init is installed. I DON'T think the crash is called by the completion routine being called because there is NO way it the ATPGetRequest should complete. I haven't sent it any packets. If i have assigned the code to be locked and in the sysheap, is there some way the ATPPBptr is getting disposed of and crashing the machine? Any ideas on what might crash the machine, given the fact that the GetRequest should NOT have been completed? Any ideas of what might get it to complete prematurely, causing the Receive routine to get called (this might mean a bug in the Receive routine) ? For instance, when the system comes up, might it do something nasty like close the socket i just opened by re-initialzing AppleTalk? Michael O'Rourke Clemson University Once again, code follows: static ATPPBptr NewPBPtr; static Ptr NTE; static Byte Socket; static int RecBuff; Receive() { OSErr err; SetUpA4(); if (RecBuff == 666) SysError(1); else if (RecBuff == 999) ShutDwnPower(); NewPBPtr->atpSocket = Socket; NewPBPtr->reqLength = sizeof(RecBuff); NewPBPtr->reqPointer = (Ptr) &RecBuff; NewPBPtr->ioCompletion = &Receive; err = PGetRequest(NewPBPtr,1); RestoreA4(); } main() { MPPPBptr OldPBPtr; EntityName Entity; OSErr err; RememberA0(); SetUpA4(); err = ATPLoad(); if (err==noErr) { err = MPPOpen(); if (err==noErr) { NewPBPtr = (ATPPBptr) NewPtr(sizeof(ATPParamBlock)); OldPBPtr = (MPPPBptr) NewPtr(sizeof(MPPParamBlock)); NTE = NewPtr(120); NewPBPtr->addrBlock.aNet = 0; NewPBPtr->addrBlock.aNode = 0; NewPBPtr->addrBlock.aSocket = 0; NewPBPtr->atpSocket = 0; err = POpenATPSkt(NewPBPtr, 0); Socket = NewPBPtr->atpSocket; NBPSetNTE(NTE,"\pComputer", "\pLABdown", "\p*", Socket); OldPBPtr->MPPinterval = 2; OldPBPtr->MPPcount = 2; OldPBPtr->MPPentityPtr = NTE; err = PRegisterName(OldPBPtr,0); NewPBPtr->atpSocket = Socket; NewPBPtr->reqLength = sizeof(RecBuff); NewPBPtr->reqPointer = (Ptr) &RecBuff; NewPBPtr->ioCompletion = 0L/*&Receive*/; err = PGetRequest(NewPBPtr,1); DisposPtr(OldPBPtr); } } RestoreA4(); }
tim@hoptoad.uucp (Tim Maroney) (07/07/89)
In article <5927@hubcap.clemson.edu> mikeoro@hubcap.clemson.edu (Michael K O'Rourke) writes: >Well, I got a multitude of responses on my last question. All saying the same >thing - remove the RememberA0() in the Receive function. I hope you also got my message mentioning the requeuing from inside a completion routine problem. This is probably not your crash, but I still don't think it's safe. >Thank you for your >help. I did remove the statement. However, it still crashes my machine. Would you mind mentioning where the crash happens? Once again, I don't mean to be persnickety, but we keep on seeing these messages where people say "it crashes" and then don't give the debugger information that would show where the crash happened. >If i have assigned the code to be locked and in the sysheap, is there some way >the ATPPBptr is getting disposed of and crashing the machine? Sure. You just allocated it with a NewPtr, after all. You didn't do a SetZone to the system heap first, so the pointer was allocated in the INIT time fake application heap. It went away as soon as the next INIT ran. (Note -- there's also a trap to allocate in the system heap directly without a SetZone, but it's not in the standard glue.) >Any ideas of what might get it to complete prematurely, >causing the Receive routine to get called (this might mean a bug in the >Receive routine) ? For instance, when the system comes up, might it do >something nasty like close the socket i just opened by re-initialzing >AppleTalk? No. It should not complete until it gets a request or is aborted. The system will not do the aborting, unless the user deselects Appletalk from the Chooser. (Actually, it's possible the call is being aborted because the parameter block is in the application heap when a Launch happens. But I don't think so.) >static ATPPBptr NewPBPtr; Why use a NewPtr on this at all? Why not just have a parameter block global variable? I notice you're also using a plain NewPtr for your Names Table Entry. Once again, it has to be allocated in the system heap if you want it to hang around. Finally, I hope you did a DetachResource on the INIT; otherwise, despite it being locked and system heap, if you don't detach it, it will be removed as soon as the INIT file is closed. Then your completion routine will jump into inner space and crash. I don't see a DetachResource in your code, though. -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com Postal: 424 Tehama, SF CA 94103; Phone: (415) 495-2934 "There are no Famous People on the net. Only some of us with bigger mouths than others." -- Dan'l Danehy-Oakes, The Roach