[Cython] [cython] Order cdef classes by inheritance before generating the code. (#223)
Stefan Behnel
stefan_ml at behnel.de
Mon May 6 21:26:08 CEST 2013
Nikita Nemkin, 05.05.2013 16:13:
> cdef classes must be (topologically) ordered by inheritance to satisfy the following dependencies:
> 1) dealloc function definition: derived classes call base class dealloc;
> 2) vtable pointer initialization in module init function.
> Wrong order causes C/C++ compilation failure for 1) and segfault on import for 2).
>
> Normally, source order is the correct order, but forward declarations can change this. See included test case for example.
> I hit this problem because I forward declare all my classes in alphabetic order (and then include class definitions from .pxi files, one class per file).
>
> The simple (although not obvious) workaround is to reorder forward delarations, but I believe it's worth fixing permanently.
> You can merge this Pull Request by running:
>
> git pull https://github.com/nnemkin/cython cdef_class_order
>
> Or you can view, comment on it, or merge it online at:
>
> https://github.com/cython/cython/pull/223
Luckily, this broke the Sage build, by running into an infinite loop while
sorting.
https://sage.math.washington.edu:8091/hudson/job/sage-build/1778/
We clearly need more tests for extension type hierarchies spread across
multiple modules.
Stefan
More information about the cython-devel
mailing list