[FFmpeg-devel] [PATCH] checkasm: Generalize crash handling

Henrik Gramner henrik at gramner.com
Fri Dec 22 23:30:07 EET 2023


On Fri, Dec 22, 2023 at 7:20 AM Rémi Denis-Courmont <remi at remlab.net> wrote:
> >> > +        checkasm_fail_func("%s",
> >> > +                           s == SIGFPE ? "fatal arithmetic error" :
> >> > +                           s == SIGILL ? "illegal instruction" :
> >> > +                           s == SIGBUS ? "bus error" :
> >> > +                                         "segmentation fault");
> >>
> >> The current code for the error print-out is both simpler and more versatile,
> >> so I don't get this.
> >
> >IMO "illegal instruction" is a far better error message than "fatal
> >signal 4" (with an implementation-defined number which nobody knows
> >the meaning of without having to look it up).
>
> The current code prints the number and the name.

Not on all supported systems. And even when it does it's in an
implementation-defined and locale-dependent form, which isn't great.

> >> +    const struct sigaction sa = {
> >> +        .sa_handler = signal_handler,
> >> +        .sa_flags = SA_NODEFER,
> >
> >That does not look very sane to me. If a recursive signal occurs, processing
> >it recursively is NOT a good idea.
>
> Following that, it actually seems safer to automatically reset the handler, using `signal()` or equivalently passing the `SA_RESETHAND` flag. Then the handler can rearm its own self if and *only* if it was able to actually handle the signal by observing a long jump. Resetting to default explicitly is no longer useful then.

Sure, that approach sounds fine.


More information about the ffmpeg-devel mailing list