diff options
author | Anton Khirnov <anton@khirnov.net> | 2024-12-12 16:04:44 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2024-12-16 09:43:19 +0100 |
commit | d2096679d5b5d76a167d038a3a2aa570e4ce37f3 (patch) | |
tree | fefd1d6989f3109c48648a87b845ddf1ad8107ba /doc | |
parent | 17e4746687abc53f0a042620a7af6dd6cea44b80 (diff) | |
download | ffmpeg-d2096679d5b5d76a167d038a3a2aa570e4ce37f3.tar.gz |
compat/w32pthreads: change pthread_t into pointer to malloced struct
pthread_t is currently defined as a struct, which gets placed into
caller's memory and filled by pthread_create() (which accepts a
pthread_t*).
The problem with this approach is that pthread_join() accepts pthread_t
itself rather than a pointer to it, so it gets a _copy_ of this
structure. This causes non-deterministic failures of pthread_join() to
produce the correct return value - depending on whether the thread
already finished before pthread_join() is called (and thus the copy
contains the correct value), or not (then it contains 0).
Change the definition of pthread_t into a pointer to a struct, that gets
malloced by pthread_create() and freed by pthread_join().
Fixes random failures of fate-ffmpeg-error-rate-fail on Windows after
433cf391f58210432be907d817654929a66e80ba.
See also [1] for an alternative approach that does not require dynamic
allocation, but relies on an assumption that the pthread_t value
remains in a fixed memory location.
[1] https://code.videolan.org/videolan/x264/-/commit/23829dd2b2c909855481f46cc884b3c25d92c2d7
Reviewed-By: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'doc')
0 files changed, 0 insertions, 0 deletions