From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] lavu/opt: Mention that AVOptions is not reentrant
Date: Thu, 6 Jun 2024 01:17:48 +0200
Message-ID: <20240605231748.GM2821752@pb2> (raw)
In-Reply-To: <ZmB0vyStERppJ-GA@andrews-2024-laptop.sayers>
[-- Attachment #1.1: Type: text/plain, Size: 2617 bytes --]
On Wed, Jun 05, 2024 at 03:22:55PM +0100, Andrew Sayers wrote:
> On Wed, Jun 05, 2024 at 09:46:16AM -0400, Ronald S. Bultje wrote:
> > Hi,
> >
> > On Wed, Jun 5, 2024 at 9:44 AM Andrew Sayers <ffmpeg-devel@pileofstuff.org>
> > wrote:
> >
> > > On Wed, Jun 05, 2024 at 03:34:50PM +0200, Paul B Mahol wrote:
> > > > On Wed, Jun 5, 2024 at 3:18 PM Andrew Sayers <
> > > ffmpeg-devel@pileofstuff.org>
> > > > wrote:
> > > >
> > > > > An external API developer might think they can use AVOptions to modify
> > > > > values
> > > > > during playback (e.g. putting a playback quality slider next to the
> > > volume
> > > > > slider). Make it clear that behaviour is not recommended.
> > > > >
> > > >
> > > > There are options that can be changed at runtime,
> > > > And it works just fine.
> > >
> > > How would an external developer know which options can be safely changed
> > > (preferably including in future versions of FFmpeg) vs. ones where their
> > > tests
> > > got lucky and happened not to trigger a read during a non-atomic write?
> > >
> >
> > If you see that happening, it would be good to submit a bug report. Right
> > now it's very abstract.
>
> I think we might be talking past each other - here's a concrete example:
>
> The private struct "SetTSContext" includes an AVOptions-accessible member
> "time_base", currently implemented as an AVRational (i.e. a pair of ints).
> write_number() in libavutil/opt.c sets options of type AV_OPT_TYPE_RATIONAL
> in such a way that a poorly-timed read could see the new numerator
> and old denominator (or the other way around).
>
> If I wrote a program that let users dynamically change the time base,
> and someone switched their timebase from 1/30 to 100/3000, one unlucky user
> might have a few frames encoded with a timebase of 100/30. Is that something
> the AVOptions API is supposed to support? If yes, the bug is that
> AVOptions access isn't guarded by a mutex. If no, there's no bug, just an
> edge case worth mentioning in the docs.
AVOption simply provides light weight access to the struct fields.
Calling AVOption non re-entrant in modifying a field you arent even allowed
to modify from 2 threads is confusing
If you want to modify a field from 2 threads that field could be some sort
of atomic type. This can then easily be added to AVOption
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
"Nothing to hide" only works if the folks in power share the values of
you and everyone you know entirely and always will -- Tom Scott
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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:[~2024-06-05 23:17 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 13:18 Andrew Sayers
2024-06-05 13:34 ` Paul B Mahol
2024-06-05 13:43 ` Andrew Sayers
2024-06-05 13:46 ` Ronald S. Bultje
2024-06-05 14:22 ` Andrew Sayers
2024-06-05 23:17 ` Michael Niedermayer [this message]
2024-06-06 8:29 ` Andrew Sayers
2024-06-06 14:24 ` Michael Niedermayer
2024-06-06 15:16 ` Andrew Sayers
2024-06-06 15:21 ` Andreas Rheinhardt
2024-06-06 15:43 ` Andrew Sayers
2024-06-05 13:50 ` Paul B Mahol
2024-06-06 16:02 ` [FFmpeg-devel] [PATCH v2] lavu/opt: Discuss AV_OPT_FLAG_RUNTIME_PARAM more explicitly Andrew Sayers
2024-06-16 16:04 ` Stefano Sabatini
2024-06-16 17:08 ` [FFmpeg-devel] [PATCH v3 0/3] s/RUNTIME/POST_INIT_SETTABLE/ Andrew Sayers
2024-06-16 17:08 ` [FFmpeg-devel] [PATCH v3 1/3] lavu/opt: Rename AV_OPT_FLAG_RUNTIME_PARAM to ...POST_INIT_SETTABLE_PARAM Andrew Sayers
2024-07-01 22:33 ` Stefano Sabatini
2024-07-02 3:58 ` Zhao Zhili
2024-07-06 9:47 ` Stefano Sabatini
2024-07-02 9:08 ` [FFmpeg-devel] [PATCH v4 0/3] s/RUNTIME/POST_INIT_SETTABLE/ Andrew Sayers
2024-07-02 9:08 ` [FFmpeg-devel] [PATCH v4 1/3] lavu/opt: Rename AV_OPT_FLAG_RUNTIME_PARAM to ...POST_INIT_SETTABLE_PARAM Andrew Sayers
2024-07-02 9:49 ` Anton Khirnov
2024-07-06 9:50 ` Stefano Sabatini
2024-07-02 9:08 ` [FFmpeg-devel] [PATCH v4 2/3] lavu/opt: Mention AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM in more places Andrew Sayers
2024-07-02 9:52 ` Anton Khirnov
2024-07-02 10:13 ` Andrew Sayers
2024-07-02 10:16 ` Anton Khirnov
2024-07-02 10:49 ` Andrew Sayers
2024-07-02 9:08 ` [FFmpeg-devel] [PATCH v4 3/3] all: s/AV_OPT_FLAG_RUNTIME_PARAM/AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM/g Andrew Sayers
2024-07-06 9:37 ` [FFmpeg-devel] [PATCH v4 0/3] s/RUNTIME/POST_INIT_SETTABLE/ Stefano Sabatini
2024-07-06 10:40 ` Paul B Mahol
2024-07-06 16:49 ` Michael Niedermayer
2024-07-06 18:03 ` Andrew Sayers
2024-07-06 10:41 ` Andrew Sayers
2024-06-16 17:08 ` [FFmpeg-devel] [PATCH v3 2/3] lavu/opt: Mention AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM in more places Andrew Sayers
2024-06-16 17:08 ` [FFmpeg-devel] [PATCH v3 3/3] all: s/AV_OPT_FLAG_RUNTIME_PARAM/AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM/g Andrew Sayers
2024-06-16 17:22 ` [FFmpeg-devel] [PATCH v3 0/3] s/RUNTIME/POST_INIT_SETTABLE/ Paul B Mahol
2024-07-01 22:26 ` Stefano Sabatini
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=20240605231748.GM2821752@pb2 \
--to=michael@niedermayer.cc \
--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