gap
gap copied to clipboard
HPC-GAP race condition in cyclotomics code
The kernel function Cyclotomic uses static local variables:
static UInt lastN; /* remember last n, dont recompute: */
static UInt phi; /* Euler phi(n) */
static BOOL isSqfree; /* is n squarefree? */
static UInt nrp; /* number of its prime factors */
This is not thread safe. As a result, if two threads performs cyclotomics computations concurrently, the results may be wrong. (I've not tried to write a reproducer, but the issue is fairly obvious).
I guess one way to fix it might be to use C11's _Thread_local. Or to use our own thread local storage system
And it was there all the time since HPC-GAP appearance?
By the way, one can also use C++'s thread_local and compile with a C++ compiler.
If we use C11, is pr #5547 good enough?