From: Henrik Gramner via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: Henrik Gramner <henrik@gramner.com>
Subject: Re: [FFmpeg-devel] [PATCH] checkasm: Generalize crash handling
Date: Thu, 21 Dec 2023 23:03:59 +0100
Message-ID: <CAFGUN0q+a73gqW5AgN+Woas6ChhAbF0bEHV+3dKuav+kK8T76g@mail.gmail.com> (raw)
In-Reply-To: <2897841.9JAYuftNni@basile.remlab.net>
On Thu, Dec 21, 2023 at 9:16 PM Rémi Denis-Courmont <remi@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).
> > + /* fall back to the default signal handler */
> > + static const struct sigaction default_sa = { .sa_handler = SIG_DFL
> > }; + sigaction(s, &default_sa, NULL);
> > + raise(s);
>
> Why raise here? Returning from the handler will reevaluate the same code with
> the same thread state, and trigger the default signal handler anyway (since
> you don't modify the user context).
No it wont, it'll get stuck in an infinite loop invoking the signal
handler over and over. At least on my system.
> > + 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. This would cause an infinite loop,
> eventually a literal stack overflow after maxing out the processor for a while.
> I'd rather let the OS kernel deal with the problem, by killing the process or
> whatever the last resort is.
>
> > +#define checkasm_save_context() setjmp(checkasm_context_buf)
> > +#define checkasm_load_context() longjmp(checkasm_context_buf, 1)
> > +#endif
>
> Been there done that and it did not end well.
> sigsetjmp() & co are necessary here.
For all intents and purposes sigjmp()/longjmp() with SA_NODEFER does
the same thing as sigsetjmp()/siglongjmp() without SA_NODEFER for this
particular use case (no infinite recursion is possible the way the
code is written). The change isn't necessary per se but it seems
reasonable and I have no objections to it.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2023-12-21 22:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-19 12:02 Martin Storsjö
2023-12-21 11:37 ` Henrik Gramner via ffmpeg-devel
2023-12-21 12:06 ` Rémi Denis-Courmont
2023-12-21 12:30 ` Martin Storsjö
2023-12-21 20:16 ` Rémi Denis-Courmont
2023-12-21 22:03 ` Henrik Gramner via ffmpeg-devel [this message]
2023-12-22 5:55 ` Rémi Denis-Courmont
2023-12-22 6:20 ` Rémi Denis-Courmont
2023-12-22 21:30 ` Henrik Gramner via ffmpeg-devel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFGUN0q+a73gqW5AgN+Woas6ChhAbF0bEHV+3dKuav+kK8T76g@mail.gmail.com \
--to=ffmpeg-devel@ffmpeg.org \
--cc=henrik@gramner.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git