[FFmpeg-devel] [PATCH] avutil/crc: always use precalculated CRC tables for known polynomials

Mark Thompson sw at jkqxz.net
Mon Oct 23 18:43:19 EEST 2017


On 23/10/17 03:56, Michael Niedermayer wrote:
> the initialization should be thread safe as it never writes a different
> value in the same spot

This is not true; please be very careful with assumptions like this.

The C standard calls this a data race and it is undefined behaviour.

It is not just a theoretical concern, either - on architectures with destructive write-hint instructions ("fill cache line with unspecified data without loading it from memory, because I'm about to overwrite all of it", exactly what you want to use (and therefore the compiler will generate) to avoid pointless loads when overwriting a large table) other threads can and do see different contents transiently when the same data is written to the location.

- Mark


More information about the ffmpeg-devel mailing list