Date: Thu, 16 Feb 1995 19:24:44 -0500 (EST) From: Kimberley Burchett Sender: Kimberley Burchett Reply-To: Kimberley Burchett Subject: interrupt handlers To: DJGPP Mailing List I have a kind of interrupt handler. It's for the mouse so what happens is the mouse driver is called (in real mode) and then it calls my handler (via a real mode callback). All of this works just fine until I call another function from inside my handler. This is my function. static void MouseHandler(_go32_dpmi_registers *regs) { event Event; // set event fields Event.info.mouse.Pos.x = regs->x.cx; Event.info.mouse.Pos.y = regs->x.dx; Event.info.mouse.lb = regs->x.bx & 1; Event.info.mouse.rb = (regs->x.bx >> 1) & 1; // did mouse change position? if ( (regs->x.ax & 1) != 0) { Event.Type = MouseMove; AddEvent(Event); } // did the buttons do anything? if ( (regs->x.ax >> 1) > 0) { Event.Type = MouseButton; AddEvent(Event); } } This works just fine if I call it directly from the main program (not in an interrupt) or if I don't call AddEvent() or if I don't pass anything to AddEvent(). As it is, it crashes with a stack retrace pointing to either where I called AddEvent or to AddEvent itself. This happens even if AddEvent doesn't do anything (I commented out all the internals and it crashed the same way). When it prints out the stack retrace, the first retrace points to AddEvent or MouseHandler, then it SIGSEGVs and ends up pointing to a different function I have. I have a feeling this is the result of it being in an interrupt, though. There is no paging going on - this is just a test prog and it only uses 76k according to topline. This is pretty urgent - I really need it to continue with my project. btw: is it okay to call malloc from an interrupt? AddEvent() calls malloc. (but that's not the problem since I can comment it out and still crash...) Kim ... job hunting ...