www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - finding a circular dependency

reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
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
Jun 21 2010
next sibling parent Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
On 06/21/2010 01:51 PM, 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
A long time ago I wrote a utility that finds these cycles. I'll see if I can't kick-start it for D2.
Jun 21 2010
prev sibling next sibling parent "Robert Jacques" <sandford jhu.edu> writes:
On Mon, 21 Jun 2010 14:51:01 -0400, Steven Schveighoffer  
<schveiguy yahoo.com> 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
Templates and particularly type inference (i.e. auto variables and auto returns, etc) are common sources of forward reference, etc issues. Also, I'd recommend diff-ing the code bases to see exactly what you changed.
Jun 21 2010
prev sibling next sibling parent torhu <no spam.invalid> writes:
On 21.06.2010 20:51, 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?
Did you add any imports at all? Try commenting them and any code that depends on them out.
Jun 21 2010
prev sibling next sibling parent reply "Rory McGuire" <rmcguire neonova.co.za> writes:
On Mon, 21 Jun 2010 20:51:01 +0200, Steven Schveighoffer  
<schveiguy yahoo.com> 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
doesn't -verbose list the modules dmd is importing? Perhaps it stops at the offending module?
Jun 22 2010
parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Tue, 22 Jun 2010 03:14:38 -0400, Rory McGuire <rmcguire neonova.co.za>  
wrote:

 On Mon, 21 Jun 2010 20:51:01 +0200, Steven Schveighoffer  
 <schveiguy yahoo.com> 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
doesn't -verbose list the modules dmd is importing? Perhaps it stops at the offending module?
It's a runtime issue, not a compiler issue. -Steve
Jun 22 2010
parent "Rory McGuire" <rmcguire neonova.co.za> writes:
On Tue, 22 Jun 2010 13:02:53 +0200, Steven Schveighoffer  
<schveiguy yahoo.com> wrote:

 On Tue, 22 Jun 2010 03:14:38 -0400, Rory McGuire  
 <rmcguire neonova.co.za> wrote:

 On Mon, 21 Jun 2010 20:51:01 +0200, Steven Schveighoffer  
 <schveiguy yahoo.com> 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
doesn't -verbose list the modules dmd is importing? Perhaps it stops at the offending module?
It's a runtime issue, not a compiler issue. -Steve
Doh! now I remember, its because of the static constructors having a specific order (from tdpl). And it only does construction when you run the app, not when compiling. (elaborating on your reply). Thanks
Jun 22 2010
prev sibling next sibling parent reply "Lars T. Kyllingstad" <public kyllingen.NOSPAMnet> writes:
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. -Lars
Jun 22 2010
parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Tue, 22 Jun 2010 05:04:18 -0400, Lars T. Kyllingstad  
<public 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
Jun 22 2010
prev sibling parent reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
On 06/21/2010 01:51 PM, 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
Hey Steve, if you haven't found your cycle yet, could you send me the source code? My utility is a bit of a mess, but I think it's working now.
Jun 24 2010
parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Thu, 24 Jun 2010 10:27:29 -0400, Ellery Newcomer  
<ellery-newcomer utulsa.edu> wrote:

 On 06/21/2010 01:51 PM, 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
Hey Steve, if you haven't found your cycle yet, could you send me the source code? My utility is a bit of a mess, but I think it's working now.
I did find it, and I will eventually incorporate my code which prints the cycle when it's found (it will be completely non-intrusive and not affect the startup performance unless a cycle is found). However, in trying to print the cycle, I've found a really disturbing bug that needs to be addressed first http://d.puremagic.com/issues/show_bug.cgi?id=4384 Also, equally disappointing, I found that the reason the cycle was added was to workaround a bug in dmd (specifically http://d.puremagic.com/issues/show_bug.cgi?id=3979). Without the code that creates the cycle, phobos doesn't compile. With the code, any program linked with phobos fails. Lovely... Great, I just gave myself more work when I was trying to just finish std.process! -Steve
Jun 24 2010