Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Tomas Härdin" <git@haerdin.se>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH 1/5] lavu/common.h: Fix UB in av_clipl_int32_c()
Date: Thu, 30 May 2024 18:48:13 +0200
Message-ID: <8012443e7bcefe0eea730fe694e38975a6a3d074.camel@haerdin.se> (raw)
In-Reply-To: <f0e52c08-7f52-4b17-9510-5c0a6ded350b@gmail.com>

tor 2024-05-30 klockan 12:42 -0300 skrev James Almer:
> On 5/30/2024 12:32 PM, Tomas Härdin wrote:
> > tor 2024-05-30 klockan 17:28 +0300 skrev Rémi Denis-Courmont:
> > > 
> > > 
> > > Le 30 mai 2024 17:07:21 GMT+03:00, "Tomas Härdin"
> > > <git@haerdin.se> a
> > > écrit :
> > > > > We should depend on punning as long as it conforms to the
> > > > > standard.
> > > > 
> > > > My mistake, I forgot type punning is allowed in C. It's UB in
> > > > C++
> > > > 
> > > > > > The standard compliant way
> > > > > > is to use memcpy()
> > > > > 
> > > > > That's way worse than union in terms of how proactively the
> > > > > compiler
> > > > > needs to optimise, and both approaches are as confirming.
> > > > 
> > > > A good compiler will do the same thing
> > > 
> > > True, and I don't care very much about memcpy vs union, as they
> > > both
> > > rely on matching representation. AFAIR, FFmpeg tends to use
> > > unions
> > > though.
> > > 
> > > > 
> > > > Maybe I can get the riscv version covered by Eva as well.
> > > > That's
> > > > beyond
> > > > the scope of this patchset
> > > 
> > > IMHO, this specific patch (and the following one) are beating
> > > dead
> > > horses. Sure there may be theoretical UB in the current code, but
> > > if
> > > there is a *better* implementation, better switch to that than
> > > bike
> > > shedding the fix for the UB.
> > 
> > Are you saying that UB is acceptable? You know the compiler is free
> > to
> > assume signed arithmetic doesn't overflow, right? If so then what
> > other
> > UB might we accept?
> 
> He did not say that... He said we should switch to a better 
> implementation rather than trying to fix the existing potentially
> buggy one.

I have a fix for demonstrable UB and Rémi is problematizing it. It is
not a "theoretical" UB - that's not how UB works. Any compiler doing
basic value analysis will find it, and is therefore free to do whatever
it wants, for example deleting all calls to av_clipl_int32_c().

We could certainly replace some of these functions with intrinsics, but
that's not what this patchset is about. I don't know what set of
compilers we support. I don't know what intrinsics they support. Am I
to be compelled to figure that out, and provide the necessary
intrinsics for all of them?

This may all seem trivial, and it is, but this patchset is also a test
balloon. Line struggle is important. What I see is the stalling of
fixes of *known broken code*. That is not encouraging.

/Tomas
_______________________________________________
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".

  reply	other threads:[~2024-05-30 16:48 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-29 22:13 Tomas Härdin
2024-05-29 22:13 ` [FFmpeg-devel] [PATCH 2/5] lavu/common.h: Fix UB in av_clip_intp2_c() Tomas Härdin
2024-05-29 22:24   ` Andreas Rheinhardt
2024-05-29 23:08     ` Tomas Härdin
2024-05-29 22:14 ` [FFmpeg-devel] [PATCH 3/5] lavu/common.h: Fix UB in av_clip_uintp2_c() Tomas Härdin
2024-05-31  0:27   ` Michael Niedermayer
2024-05-29 22:14 ` [FFmpeg-devel] [PATCH 4/5] lavu/intmath.h: Fix UB in ff_ctz_c() and ff_ctzll_c() Tomas Härdin
2024-05-30  7:54   ` Rémi Denis-Courmont
2024-05-30  9:50     ` Tomas Härdin
2024-05-30 12:29       ` Hendrik Leppkes
2024-05-30 13:06       ` Rémi Denis-Courmont
2024-05-30 14:03         ` Tomas Härdin
2024-05-30 14:32           ` Rémi Denis-Courmont
2024-05-31  0:43           ` Ronald S. Bultje
2024-05-31  0:41     ` Michael Niedermayer
2024-05-31  5:48       ` Rémi Denis-Courmont
2024-05-31  0:31   ` Michael Niedermayer
2024-05-29 22:15 ` [FFmpeg-devel] [PATCH 5/5] lavu/mathematics: Return early if either a or b is zero Tomas Härdin
2024-05-31  0:22   ` Michael Niedermayer
2024-05-31 15:21     ` Tomas Härdin
2024-05-29 22:31 ` [FFmpeg-devel] [PATCH 1/5] lavu/common.h: Fix UB in av_clipl_int32_c() Andreas Rheinhardt
2024-05-30  9:48   ` Tomas Härdin
2024-05-30  6:41 ` Rémi Denis-Courmont
2024-05-30  9:40   ` Tomas Härdin
2024-05-30 11:50     ` Rémi Denis-Courmont
2024-05-30 14:07       ` Tomas Härdin
2024-05-30 14:28         ` Rémi Denis-Courmont
2024-05-30 15:32           ` Tomas Härdin
2024-05-30 15:38             ` Rémi Denis-Courmont
2024-05-31  1:03               ` Michael Niedermayer
2024-06-03  7:32                 ` Rémi Denis-Courmont
2024-06-03 21:21                   ` Michael Niedermayer
2024-05-30 15:42             ` James Almer
2024-05-30 16:48               ` Tomas Härdin [this message]
2024-05-30 17:49                 ` Rémi Denis-Courmont
2024-05-30 19:07                   ` Michael Niedermayer
2024-05-30 19:20                     ` Rémi Denis-Courmont
2024-05-31 15:23                   ` Tomas Härdin
2024-06-14 12:31 ` Tomas Härdin

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=8012443e7bcefe0eea730fe694e38975a6a3d074.camel@haerdin.se \
    --to=git@haerdin.se \
    --cc=ffmpeg-devel@ffmpeg.org \
    /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