finding a circular dependency

Steven Schveighoffer schveiguy at yahoo.com
Tue Jun 22 04:04:13 PDT 2010


On Tue, 22 Jun 2010 05:04:18 -0400, Lars T. Kyllingstad  
<public at kyllingen.nospamnet> wrote:

> On Mon, 21 Jun 2010 14:51:01 -0400, Steven Schveighoffer wrote:
>
>> I've been trying to get a modified version of std.process to compile
>> (with Lars K's changes) for windows, and phobos finally compiled.
>>
>> So I built a little test program, compiled it, and I get the following
>> error message:
>>
>> object.Exception: circular dependency in module std.stdio.
>>
>> Great.  How did that happen?  Being that I didn't write std.stdio, only
>> modified it slightly (and certainly didn't change any imports), I
>> haven't the foggiest where this problem is.  Given that the runtime can
>> prove there is a circular dependency, and apparently knows the names of
>> the modules, how about showing me the cycle?
>>
>> :P
>>
>> I do not look forward to tracking this one down...
>>
>> -Steve
>
>
> I think the only places that exception can be thrown are lines 1770 and
> 1830 of object.d.  Luckily there are a few debug(PRINTF)printf()s
> nearby.  You could try building druntime with -debug=PRINTF.  When the
> static constructors are run, hopefully you'll see something like
>
>   ...
>   module[x] = std.stdio
>   ...
>   module[y] = module.depending.cyclically.on.stdio
>   module[z] = std.stdio
>   object.Exception: Cyclic dependency in module std.stdio.

This is a good idea.

I'm going to look at the runtime to see if I can add code that prints the  
cycle only on failure.  I think such code could be invaluable.  I wonder  
if a stack trace would be enough...

-Steve


More information about the Digitalmars-d mailing list