[FFmpeg-devel] [PATCH] tests/checkasm: prevent a segmentation fault when calling strncmp()

Sean McGovern gseanmcg at gmail.com
Thu Jan 16 23:35:42 EET 2025


On Thu, Jan 16, 2025 at 4:04 PM Martin Storsjö <martin at martin.st> wrote:
>
> On Thu, 16 Jan 2025, Sean McGovern wrote:
>
> >> This feels like less of an issue with strncmp, and more of an issue with
> >> the spec for main() and argc/argv; how do you do to end up with a NULL
> >> entry in argv[i] for 0 <= i < argc?
> >
> > If 'checkasm' is run without arguments, argv[i] would be NULL since argc == 1.
>
> If we have argc == 1, and we run the loop "for (i = 1; i < argc; i++)", it
> will never even enter the loop body, right?
>
> > It only really tripped up on GCC with Address Sanitizer enabled, but
> > the comment regarding
> > how POSIX does not require a length check on either argument means we should
> > be defensive.
> >
> > In fact, even 'checkasm --test=blah' triggered the segmentation fault
> > under ASan.
>
> Sorry, I don't see how that would happen, and I can't reproduce it.
>
> // Martin

Big apologies for wasting your and the lists' time... this is probably
GCC 14.x's fault.
GCC 12.2.0 + ASan on the same machine works just fine.

This is the 3rd time in the past few weeks I've been burnt by GCC 14.
Ignore this patch and I need a break before I put a head-sized
indentation in my table.

Respectfully,
Sean McGovern


More information about the ffmpeg-devel mailing list