[FFmpeg-devel] [PATCH 2/3] swscale/swscale: Fix races when using unaligned strides/data

Michael Niedermayer michael at niedermayer.cc
Sun Sep 19 17:47:28 EEST 2021


On Sat, Sep 18, 2021 at 05:43:25AM +0200, Andreas Rheinhardt wrote:
> In this case the current code tries to warn once; to do so, it uses
> ordinary static ints to store whether the warning has already been
> emitted. This is both a data race (and therefore undefined behaviour)
> as well as a race condition, because it is really possible for multiple
> threads to be the one thread to emit the warning. This is actually
> common since the introduction of the new multithreaded scaling API.
> 
> This commit fixes this by using atomic integers for the state;
> furthermore, these are not static anymore, but rather contained
> in the user-facing SwsContext (i.e. the parent SwsContext in case
> of slice-threading).
> 
> Given that these atomic variables are not intended for synchronization
> at all (but only for atomicity, i.e. only to output the warning once),
> the atomic operations use memory_order_relaxed.
> 
> This affected nv12, nv21, yuv420, yuv420p10, yuv422, yuv422p10 and
> yuv444 filter-overlay FATE-tests.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
> Of course, one could also use static atomic integers.

should be ok

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Modern terrorism, a quick summary: Need oil, start war with country that
has oil, kill hundread thousand in war. Let country fall into chaos,
be surprised about raise of fundamantalists. Drop more bombs, kill more
people, be surprised about them taking revenge and drop even more bombs
and strip your own citizens of their rights and freedoms. to be continued
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20210919/d1ba47a3/attachment.sig>


More information about the ffmpeg-devel mailing list