If module A imports module B, and module B imports module A, minigrace will run forever — or until the host OS runs out of processes. It will start compiling A, which will launch a compile of B, which will launch a compile of A, and so on.
There used to be logic in xmodule that attempted to detect his situation — it was removed in commit 0cf0402 because it did not work. It used the modules entry of the compiled code's gct dictionary to detect imports, but because this entry is not available until after compilation has finished (and compilation never finished), the cycle-detection code was never run.
Instead, I believe that we need to build the imports graph before compilation starts. This graph could then be searched for cycles. As an added benefit, if no cycles are found, a topological sort of the graph will yield the dependencies for compiling the graph of modules that may enable some of them to be compiled in parallel.
If module
A
imports moduleB
, and moduleB
imports moduleA
, minigrace will run forever — or until the host OS runs out of processes. It will start compilingA
, which will launch a compile ofB
, which will launch a compile ofA
, and so on.There used to be logic in xmodule that attempted to detect his situation — it was removed in commit 0cf0402 because it did not work. It used the
modules
entry of the compiled code'sgct
dictionary to detect imports, but because this entry is not available until after compilation has finished (and compilation never finished), the cycle-detection code was never run.Instead, I believe that we need to build the imports graph before compilation starts. This graph could then be searched for cycles. As an added benefit, if no cycles are found, a topological sort of the graph will yield the dependencies for compiling the graph of modules that may enable some of them to be compiled in parallel.