Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/tfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,15 @@ int validate_tfile_pow_fp(FILE *fp, int trust)
void (*SIGINT_old)(int);
BTRAILER bt;
long long len, skip;
int ecode, errnum;
/* ecode is read outside a critical section (the `while (ecode == VEOK)`
* loop condition) and written inside OMP critical sections. volatile
* prevents the compiler from caching it in a register and forces each
* loop iteration to re-read from memory. Combined with the memory
* barriers implicit in OMP critical section entry/exit, this gives
* correct shared-flag semantics across threads on all real hardware,
* including weakly-ordered architectures (ARM64, RISC-V). */
volatile int ecode;
int errnum;

/* init */
ecode = VEOK;
Expand Down
Loading