CastXML / pygccxml

pygccxml is a specialized XML reader that reads the output from CastXML or GCCXML. It provides a simple framework to navigate C++ declarations, using Python classes.
Boost Software License 1.0
131 stars 45 forks source link

ostream recursive loop in find_noncopyable_vars #71

Closed dermont123 closed 7 years ago

dermont123 commented 7 years ago

Hi, I found the problem I had with the recursive loop in find_noncopyable_vars. It appears to happen for a class with a stream variable(std::istream*) and when base classes are known for ostream in class_declaration.hierarchy_info_t in is_noncopyable().

I think ::std::basic_ostream processes it base class std::basic_ios which holds a pointer to ostream and so on.

Stream.zip

iMichka commented 7 years ago

Thanks. I added a small test to the hot fix/v1.8.6 branch, which reproduces the problem, based on your code. I will investigate this.

iMichka commented 7 years ago

I am making good progress. Took me some time, but I was able to write a simplified test that shows an equivalent problem.

The situation in too sstream complicated. I do not know the internals of that code, there are a lot of declarations in there, so it is difficult to debug.

In fact, it is quite easy to end up in that the infinite recursion state with a hierarchy of 3 classes, and some pointers holding references to one of the other classes.

I will work on a fix now. I probably just need to keep a list of the classes that have already been visited, and prevent them to be visited again. I'll work on this tomorrow though, writing the test and debugging the code already took me forever. But it is an interesting problem. Weird nobody ever stumbled over this before, because it is not an unlikely scenario.

iMichka commented 7 years ago

I pushed a fix to the hotfix/v1.8.6 branch. Could you test this please?

dermont123 commented 7 years ago

Thanks, it fixed the recursion issue for me.

iMichka commented 7 years ago

Cool. I will publish the 1.8.6 release with the fix during the weekend.