Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler crashes when fused type is used as part of C++ template specialization #2943

Open
atsuoishimoto opened this issue May 2, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@atsuoishimoto
Copy link

commented May 2, 2019

Following Cython code with fused type cannot be compiled with Cython 0.29.7/ Python 3.7.2/Ubuntu linux 18.04.

This error happends only if I use fused type to specialize template.

cdef extern from "func.h":
    void func1[L](L arg);

ctypedef fused Num:
    long

def test(Num n):
    cdef void (*p_func1) (Num)
    p_func1 = func1[Num]

The error is:

1/1] Cythonizing test.pyx
/usr/local/lib/python3.7/site-packages/Cython/Compiler/Main.py:367: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /home/ishimoto/src/cython_bug/test.pyx
  tree = Parsing.p_module(s, pxd, full_module_name)

Error compiling Cython file:
------------------------------------------------------------
...
ctypedef fused Num:
    long

def test(Num n):
    cdef void (*p_func1) (Num)
    p_func1 = func1[Num]
                  ^
------------------------------------------------------------

test.pyx:10:19: Compiler crash in AnalyseExpressionsTransform

ModuleNode.body = StatListNode(test.pyx:2:0)
StatListNode.stats[1] = FusedCFuncDefNode(test.pyx:8:0,
    defaults = [...]/1,
    fused_compound_types = [...]/1,
    match = "dest_sig[{{dest_sig_idx}}] = '{{specialized_type_name}}'",
    no_match = 'dest_sig[{{dest_sig_idx}}] = None',
    nodes = [...]/1,
    specialized_pycfuncs = [...]/1)
FusedCFuncDefNode.stats[1] = DefNode(test.pyx:8:0,
    modifiers = [...]/0,
    name = 'test',
    np_args_idx = [...]/0,
    num_required_args = 1,
    outer_attrs = [...]/2,
    py_wrapper_required = True,
    reqd_kw_flags_cname = '0',
    specialized_signature_string = 'long',
    used = True)
File 'Nodes.py', line 436, in analyse_expressions: StatListNode(test.pyx:9:4)
File 'Nodes.py', line 5156, in analyse_expressions: SingleAssignmentNode(test.pyx:10:19)
File 'Nodes.py', line 5309, in analyse_types: SingleAssignmentNode(test.pyx:10:19)
File 'ExprNodes.py', line 895, in coerce_to: IndexNode(test.pyx:10:19,
    is_subscript = True,
    result_is_used = True,
    type_indices = [...]/1,
    use_managed_ref = True)

Compiler crash traceback from this point on:
  File "/usr/local/lib/python3.7/site-packages/Cython/Compiler/ExprNodes.py", line 895, in coerce_to
    for signature in src_type.get_all_specialized_function_types():
  File "/usr/local/lib/python3.7/site-packages/Cython/Compiler/PyrexTypes.py", line 2986, in get_all_specialized_function_types
    if self.entry.fused_cfunction:
AttributeError: 'CFuncType' object has no attribute 'entry'
Traceback (most recent call last):
  File "setup.py", line 16, in <module>
    ext_modules=cythonize(ext_modules),
  File "/usr/local/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1097, in cythonize
    cythonize_one(*args)
  File "/usr/local/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1220, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: test.pyx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.