httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Jagielski <...@jaguNET.com>
Subject Re: Solaris bus error?
Date Fri, 26 Jun 1998 21:19:18 GMT
Yep... This is what I meant, although stating that the patch
be submitted anyway was not a clear indication of that. If something
is impossible, and the code "assumes" that the impossible does not
happen, then it's safest to "do something" to catch that impossible
case, even if it's just bailing out with a "The Impossible Just
Happened" error message. 

So, of course, the patch Dean "submitted" would not fit into that
catagory and his resistance to including it as written was well
founded. What I was suggesting, in, I guess, a not-too-clear
method, was that if we were getting bitten by the impossible
happening, the code should do something, ideally dumping core
with an error at that place. "Masking" the error ain't right,
and I wasn't advocating that, but sticking our heads in the sand
saying "Can't happen" didn't make sense either :/

Alexei Kosut wrote:
> 
> On Fri, 26 Jun 1998, Ben Laurie wrote:
> 
> > Jim Jagielski wrote:
> > > 
> > > All I'm saying is that it's common, recommended, taught and safe
> > > practise to handle such "impossible" cases, esp when it's so simple.
> > > That's not ignoring your point of, if it does fix something, then
> > > we have a more serious problem.
> > 
> > No, no! Never handle a case that should not occur! That just hides bugs.
> 
> I agree. However, you should not assume that an impossible case will not
> happen. i.e. if num should be lower than 6, saying
> 
> if (num < 5) do_something;
> else if (num == 5) /* num must be 5 */ do_something_else;
> 
> do_something_that_relies_on_one_of_the_two_other_functions_being_called;
> 
> Isn't a good idea. But neither is:
> 
> if (num < 5) do_something;
> else if (num >= 5) do_something_else;
> 
> I think the proper case is
> 
> if (num < 5) do_something;
> else if (num == 5) do_something_else;
> else quit_with_an_error;
> 
> or alternately
> 
> assert(num < 6)
> if (num < 5) do_something
> else /* num really must be 5 now */ do_something_else;
> 
> Or whatever...
> 
> -- Alexei Kosut <akosut@stanford.edu> <http://www.stanford.edu/~akosut/>
>    Stanford University, Class of 2001 * Apache <http://www.apache.org> *
> 
> 
> 


-- 
===========================================================================
   Jim Jagielski   |||   jim@jaguNET.com   |||   http://www.jaguNET.com/
            "That's no ordinary rabbit... that's the most foul,
            cruel and bad-tempered rodent you ever laid eyes on"

Mime
View raw message