delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/22/18:52:08

From: jp-morris <Joseph DOT Morris AT uwe DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: 2.02 - atexit and exceptions?
Date: Tue, 22 Dec 1998 23:02:30 +0000
Lines: 66
Message-ID: <36802506.8847AB34@uwe.ac.uk>
NNTP-Posting-Host: 195.147.218.132
Mime-Version: 1.0
X-Mailer: Mozilla 4.06 [en] (Win95; I)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I've just upgraded to DJGPP 2.02 and I am having a problem with it.
I'm using the MIDAS sound system to produce sound output in a large,
complex program.

Because of this, I have several interrupt handlers running continuously,
to service the audio DMA transfers and controlling the clock.

I use atexit() to catch the program ending, and it calls the MIDAS
functions to shut down the interrupt processes safely.

This has worked perfectly in 2.01, but it is causing havoc in 2.02.

From my experiments it seems that atexit is failing to operate at all
if the cause of the program exit is an exception.

This means that if my program crashes or causes an int 3 to get a stack
trace, the clock and the DMA processes seem to be still running even
when the program has finished and is back in DOS.
I end up with a GPF or PAGEFAULT in RMCB and the system clock stops.

More importantly, I have found it is actually overwriting parts of my
disk cache software while it is running: not good.

Here's a sample program which demonstrates the problem:

============================

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

void term_function()
{
printf("TermFunction\n");
remove("$$$.$$$");
}

main()
{
FILE *fp;

printf("Registering term_function\n");
atexit(term_function);

printf("Creating dummy file\n");
fp=fopen("$$$.$$$","w");
fputs("This should have been deleted by term_function\x1a\n",fp);
fclose(fp);

printf("Press X to cause an exception or any other key to exit\n");
if(getch()=='x')
    {
    printf("Exiting ABnormally\n");
    asm("int $3");
    }

printf("Exiting normally\n");
}

================================

Now.  Under 2.01 this works perfectly in all cases.
Under 2.02 this does NOT work if you press X:
the file '$$$.$$$' is still present and the message is never printed.
1
Does anyone know why this is happening, and what I can do about it?

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019