Re: Threadsanitizer Detection on GM
Bob Friesenhahn <[email protected]> Tue, 12 Feb 2019 11:37:47 -0600 (CST)
| Newsgroups | gmane.comp.video.graphicsmagick.bugs |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 13 Feb 2019, Hongxu Chen wrote: > > Yes, that is pass-by-value. > But the problem is that there might also "(atomic) write row_count" > between these lines, > which causes the inconsistency. > > atomic write row_count at line:123 > <write> > read row_count at line:124 (QuantumTick) > <write> > read row_count at line:125 (MagickMonitorFormatted) > > Therefore it's still possible that row_count at line:124 and line:125 are > different. Definitely the value can be different when reading a shared integer value which may be updated at any time by any thread. This would be true if a lock is held around individual access, but not across the multiple accesses. The updated value could be sampled and copied to a variable on the local thread stack (just like 'status' is copied to 'thread_status' at a point where there is an implicit flush) so it is consistent while used within the thread and there is no contention. QuantumTick() is a macro and refers to this value multiple times. It is likely that the value used by the macro is in a register, or in L1 cache, or optimized in interesting ways. If the value changes while QuantumTick() is using it, it might produce a "tick" outside of its normal cadence. Regardless, this issue appears to be totally benign in terms of function of the software. It is only there for the progress monitor, which is usually not active. Bob