Date: Tue, 16 Dec 1997 20:11:30 -0500 (EST) Message-Id: <199712170111.UAA21816@delorie.com> From: DJ Delorie To: djgpp-workers AT delorie DOT com Subject: [44699 AT ef DOT gc DOT maricopa DOT edu: Bug fix for exception problems under Win95] Precedence: bulk ------- Start of forwarded message ------- Date: Mon, 15 Dec 1997 23:03:28 -0700 (MST) From: "Joshua James Turpen" <44699 AT ef DOT gc DOT maricopa DOT edu> To: dj AT delorie DOT com Subject: Bug fix for exception problems under Win95 Hello. I've found a subtle bug in the file /src/libc/go32/exceptn.S. This bug causes instability in the exception->signal mechanism when running under Windows 95. To fix the problem, the line 113 in exceptn.S currently reads: andb $0xfe, %ah /* mask off trap flag */ It should be changed to andb $0xfc, %ah /* mask off debug & int flag */ I've tested the change as much as I could, under Win 3.1, Win95, CWSDPMI, QDPMI, and PMODE/DJ. It does not cause any side-effects, as far as I can tell. Both Charles Sandmann and I are a bit baffled as to why the change works at all, since the flags aren't restored until the IRET at the end of longjmp, and the interrupt flag is ignored by the IRET when CPL=3. This changed shouldn't do anything at all, but it does! (At least under Win95) Josh Turpen 44699 AT ef DOT gc DOT maricopa DOT edu p.s. Here is the test program that fails under Windows 95 with the current version of DJGPP: (It takes a few minutes to crash). With the fixed exceptn.S I couldn't get it to crash, along with a few other test programs. - ----------------------Test Program-------------------------------- #include #include #include /* Comment */ int tick; void sig_handler(int signum); main() { struct itimerval t; t.it_interval.tv_sec = 0; t.it_interval.tv_usec =100; t.it_value.tv_sec = 0; t.it_value.tv_usec = 100; signal(SIGALRM, sig_handler); setitimer(ITIMER_REAL, &t, NULL); while(!kbhit()) { printf("Tick %d\n", tick); } } void sig_handler(int signum) { tick++; } ------- End of forwarded message -------