On 3/3/15 12:40 PM, rumbu wrote:
I encountered the following error:
First-chance exception: object.Exception Aborting: Cycle detected
between modules with ctors/dtors:
system.globalization -> internals.locale ->
system.runtime.interopservices -> system.io -> system.globalization at
src\rt\minfo.d(162)
Only one of the listed modules has a static contructor
(system.globalization) and that constructor doesn't use any information
from other modules.
It's a complex problem. Because we don't control the linker, we cannot
establish an order of execution for the module system. It must be a
directed acyclic graph. Although, cycles are allowed that only involve a
single module with ctor/dtors, or with no ctor/dtors. But we have to
detect it at runtime during startup.
two of those modules should have static ctor or dtor (they may have
either to cause the error).
The message is not too helpful, I have no clue where to start searching
for the error source, the source code has more than 25k LOC. In fact, I
don't believe this error is true, since I have only two non-linked
modules with static contructors.
Just look for "static this" and "static ~this" inside those files
identified.
Stack trace is also not helpful at all:
KernelBase.dll!7512f896
sharp.exe!_D2rt9deh_win329throwImplFC6ObjectZv() + 0x1c bytes D
sharp.exe!_D2rt5minfo11ModuleGroup9sortCtorsMFZ4sortMFKAPyS6object10ModuleInfokZv()
+ 0x27c bytes D
sharp.exe!_D2rt5minfo13rt_moduleCtorUZ14__foreachbody1MFKS2rt14sections_win3212SectionGroupZi()
+ 0xf bytes D
sharp.exe!typeid(const(immutable(char)[]))() + 0xb020 bytes D
The stack trace only shows the stack for when the DAG is being
constructed, it is not a stack trace of trying to RUN those module ctors.
-Steve