Zefram <zefram@fysh.org> wrote: > static void THX_wrap_op_checker(pTHX_ Optype opcode, > Perl_check_t new_checker, Perl_check_t *old_checker_p) > { > if(*old_checker_p) return; > OP_REFCNT_LOCK; > if(!*old_checker_p) { > *old_checker_p = PL_check[opcode]; > PL_check[opcode] = new_checker; > } > OP_REFCNT_UNLOCK; > } Do we support any platforms where an access to a Perl_check_t might not be atomic? (For that matter, do any such platforms exist? Since it's a function pointer, that would presumably mean 64-bit platforms which only do atomic memory accesses of up to 32 bits.) If so, I think the OP_REFCNT_LOCK needs to precede the initial test/return, to avoid this race: 1. Thread A loads the first half of *old_checker_p, which is all-bits-zero 2. Thread B takes the lock 3. Thread B writes 64 bits into *old_checker_p; the second half happens to be all-bits-zero 4. Thread B releases the lock 5. Thread A loads the second half of the new value of *old_checker_p (all-bits-zero again) 6. Thread A thinks the full value was 0, so continues; but it wasn't, so it should have returned Or am I misunderstanding something? -- Aaron Crane ** http://aaroncrane.co.uk/Thread Previous | Thread Next