`Error, collector is not reentrant` after previously interrupting code.
When working with PcGroups, I sometimes interrupt calculations because they take too long, e.g.
```
^CError, user interrupt
Stack trace:
*[1] v[gn] := v[gn] + ew[sp];
@ /opt/gap/4.16.0-beta1/lib/rwspcsng.gi:189
[2] CollectWordOrFail( col, l, word )
@ /opt/gap/4.16.0-beta1/lib/rwspcclt.gi:491
[3] ReducedForm( rws, left * right )
@ /opt/gap/4.16.0-beta1/lib/rws.gi:353
[4] ReducedProduct( col, gk, ReducedProduct( col, gj, gi ) )
@ /opt/gap/4.16.0-beta1/lib/rwspcclt.gi:76
[5] FinitePolycyclicCollector_IsConfluent( col, false )
@ /opt/gap/4.16.0-beta1/lib/rwspcclt.gi:189
... at *stdin*:8073
you can 'return;'
```
What *very* rarely happens, is that when I use `quit;` and then construct a new PcGroup and try to do calculations with it, I get hit with this:
```
Error, collector is not reentrant
Stack trace:
*[1] Error( "collector is not reentrant" );
@ /opt/gap/4.16.0-beta1/lib/rwspcsng.gi:98
[2] CollectWordOrFail( col, v, w )
@ /opt/gap/4.16.0-beta1/lib/rwspcclt.gi:425
[3] CollectWord( sc, av, y );
@ /opt/gap/4.16.0-beta1/lib/rwspcsng.gi:275
[4] SingleCollector_Solution( sc, gn[i], id )
@ /opt/gap/4.16.0-beta1/lib/rwspcsng.gi:793
[5] SingleCollector_MakeInverses( sc );
@ /opt/gap/4.16.0-beta1/lib/rwspcsng.gi:812
... at *stdin*:8115
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
```
Just running `quit;` again and restarting whatever calculation I was doing, tends to fix the problem.
This has been happening for a long time (at least quite a few GAP versions), but it's very hard to recreate since it seems to rely on a user interrupt happening at a very specific moment.
I suspect this is due to the interrupt happening in the middle of `SingleCollector_CollectWord`:
https://github.com/gap-system/gap/blob/4a52d83616815bdd7dae6d9c8911a014ce49465b/lib/rwspcsng.gi#L74-L99
and the variable `SingleCollector_CollectWordRunning` never gets set to `false` due to the interruption. But because it gets set to `false` again before the `not reentrant` error is throwing, it works again from then onwards.
This seems to be a way to enforce that no two instances of this function can run at the same time, but I don't immediately see *why* that should be prevented.
2 条评论