Re: [AD] segfaulting on bad midis + workaround

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Thu, Jun 15, 2000 at 01:02:58PM +0200, Eduard Bloch wrote:
> #include <hallo.h>
> George Foot wrote on Wed Jun 14, 2000 um 03:43:27PM:
> 
> > message in `allegro_error', saying what went wrong, and rely on
> > the user to catch the error return from `play_midi', if they
> > care about it.
> 
> That's the point, they the don't do. Even if this error isn't catched
> up, the program will crash in any case. So it's better to exit cleanly,
> IMHO.

But your exit isn't very clean. :)  Calling `allegro_exit' is
not really sensible inside an Allegro routine, so I'm assuming
you actually meant to exit the program completely (but maybe
this isn't what you meant).  Given your patch, I'd expect the
program to crash fairly soon after that point, if you just
deinitialise Allegro and let the program carry on running.

Assuming that's what you meant, I disagree with you on two
counts -- firstly, I'm not sure whether we should really be
detecting this error, if it only occurs because of a corrupted
datafile.  Secondly, even if we should detect this error and do
something safe, I think the most we should do is return an error
to the program (and not play the MIDI) and let it handle the
problem however it prefers.  That's the documented behaviour of
`play_midi' -- it even mentions failure to load patches as a
possible reason for returning an error.

Making the change so that it detects the problem as you did, but
returns an error code, would (should) stop the demo game
crashing for you, even though it doesn't check the return value.
The demo game doesn't really care whether its music can play.
If it did, it could check what we put in `allegro_error', and
complain to the user.


George

-- 
Random project update:
27/04/2000: AllegroGL alpha 7 released, fixing silly omission in alpha 6
        http://AllegroGL.sourceforge.net/



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/