www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/10/10:30:54

From: "Chris Jones" <chris AT mynos DOT freeserve DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Possible bug in Allegro 3.1
Date: Sat, 9 Jan 1999 15:49:53 -0000
Organization: Customer of Planet Online
Lines: 36
Message-ID: <77ag71$s0j$1@news5.svr.pol.co.uk>
NNTP-Posting-Host: modem-55.zoloft.dialup.pol.co.uk
X-Trace: news5.svr.pol.co.uk 915981345 28691 62.136.95.55 (10 Jan 1999 15:15:45 GMT)
NNTP-Posting-Date: 10 Jan 1999 15:15:45 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Newsreader: Microsoft Outlook Express 4.72.3110.5
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Having just upgraded from Allegro 3.0 to 3.1, I re-compiled a program which
uses it. The program was still a bit buggy - it used to occasionally cause
SIGSEGVs and the like. Since upgrading to 3.1, it now just crashes with
'Shutting down Allegro' repeatedly printing on the screen.
I investigated this, and found that my program was calling allegro_init()
twice by accident. This was not a problem with Allegro 3.0, but it seems
that 3.1's allegro_init() saves the old signal handlers to call when a fault
occurs (which, of course, on the second call to allegro_init() are its own
handlers). Therefore on a SIGSEGV it calls its own handler recursively, and
never exits.

For example, compiling this program under 3.1 will hang the system:
int main() {
  int zero,cause_fault;
  allegro_init();
  allegro_init();
  zero=0;
  cause_fault = 5 / zero;
  }

The strange thing is, that Allegro maintains the _allegro_count variable
with how many times allegro_init() has been called. So, a simple fix for
this would be to only call the signal-setting calls in allegro_init() if
_allegro_count is 0.

I know this is a very minor bug, and that people shouldn't call
allegro_init() twice anyway, but it can be frustrating to find what's wrong
with the program.

Chris Jones
-------------------------------
Tip of the year: "Friends are just enemies who don't have the guts to kill
you"



- Raw text -


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