Crashes with cyclic class dependency graph

Nicolai Haehnle nhaehnle at
Sun Feb 14 12:10:45 UTC 2010


I've run into a weird problem with the cppduchain code. Consider the
following (obviously incorrect) code:

struct B;

struct A : B {};

struct B : A {};

void test() {
   B b;

You're pretty much guaranteed to hit a crash after a little bit of
editing. The reason for all these different crashes is that many
places in the code traverse the dependency graph recursively, and
they're bound to run out of stack pretty quickly. Of course the above
code is incorrect, but KDevelop should obviously not crash. What is
the preferred solution for this, though? Forbid the introduction of
cycles into the dependency graph while parsing the code? And how would
one achieve that?

Incidentally, I ran into this problem on completely valid code, where
the parser apparently didn't understand namespaces correctly; but
that's I separate issue which I'm going to investigate separately now.


More information about the KDevelop-devel mailing list