Collin Funk wrote:
> >> >    - either an abort(),
> >
> > Recall: abort() is the preferred way for a programmer to say "if this
> > situation occurs, I made a mistake, and I want to be notified".
> >
> >> Best not do that in a lib I think.
> >
> > Oh, that's the rule that I heard 25 years ago, when working on X11. libX11
> > had no single call to abort(). And was libX11 reliable, or was it buggy?
> > It was buggy, because when an application never crashes via abort(), only
> > via "bad event" or so, users have no way to produce useful bug reports.
> > ...
> 
> I'd assume any issues that libX11 has (*) would still exist if they had
> aborts.

No. libX11 would have had its bugs fixed earlier if they had used abort().

It's all about the feedback loop between developers and users, and abort()
is part of the implementation of that feedback loop.

Recall where all this comes from: In the 1980ies and 1990ies, most software
was proprietary, and the vendors did not _want_ their users to report bugs.(*)
That's the reason why they
  - did not use abort(),
  - instead use assert(), with the effect that the production binaries,
    compiled with NDEBUG, would seriously corrupt memory instead of crashing
    as early as possible.

In the Free Software world, we have been using bug trackers since the
beginning (and mailing lists even before that). We _do_ want to hear
about bugs, from the (small) group of users who are able to use a
debugger, or even automatically via 'apport' or 'systemd-coredump'.
This is why we all ought to prefer abort() over assert(). With assert()
and the concept of "production binaries" you prevent yourself from
getting bug reports with stack traces so often.

> I generally agree with Pádraig that it should be avoided in
> libraries, but if the situation truly should never happen, then it seems
> fine.

The special thing about libraries (as opposed to programs) is that
the program might want to save user data before it terminates, and
therefore a library should not have a significant probability > 0
of terminating the process. This is why libraries should not use
xmalloc(). - Whereas abort() is for situations that *should never happen*,
if the programmer was right.

Bruno

(*) Not even users in the same company. In 1986, as an intern at HP, I
discovered an endless loop in an HP product. I was prohibited from
reporting it to the developers, who were located in the same company,
just 50 km away.




Reply via email to