Path: utzoo!attcan!uunet!lll-winken!lll-ncis!helios.ee.lbl.gov!pasteur!ucbvax!bloom-beacon!apple!xanadu!bob From: bob@xanadu.COM (Bob Schumaker) Newsgroups: comp.sys.mac.programmer Subject: Stack manipulation problems Message-ID: Date: 6 Jan 89 03:17:29 GMT Organization: Xanadu Operating Company, Palo Alto, CA Lines: 26 We are in the process of implementing a multi-tasking executive and we are running into a problem when we move the stack. The premise is that we can allocate some storage in the heap, make the stack pointer point to this storage (after setting up A6 and then copying the stack frame) and restarting execution with the new values (using setjmp/longjmp under LSC 3.01p3). (This clever hack was suggested to us by Michael McClary. It is known to work just fine on various onther systems, so the principle is sound if not particularly pleasing to purists). By the way, the stack sniffer *is* disabled during the process. As soon as the stack pointer and A6 contain the new values, the Mac environment behaves strangely -- the menus highlight with a black rectangle (no highlighted text shows) and/or the text disappears from the menus. Things get progressively weirder from there. As a check, we just copied the stack frame (using the same method) several K below the stack pointer (unused memory between the heap and the stack) and set up all the appropriate registers in an identical fashion -- and everything worked just fine! Does anyone out there have any idea what's going on? The only thing that we can figure is that somewhere in the Mac system software, some routine cares where the stack is -- someone that is, besides the stack sniffer, which *should* be disabled at this point... Thanks in advance.