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

[BUG] v3.0.4: Compiler crash in AnalyseExpressionsTransform #5771

Closed
Baekalfen opened this issue Oct 18, 2023 · 2 comments · Fixed by #5773
Closed

[BUG] v3.0.4: Compiler crash in AnalyseExpressionsTransform #5771

Baekalfen opened this issue Oct 18, 2023 · 2 comments · Fixed by #5773
Labels
Milestone

Comments

@Baekalfen
Copy link
Contributor

Describe the bug

When compiling PyBoy, it immediately started failing when 3.0.4 was released.

The error will look like this on Python 3.11:

Error compiling Cython file:
------------------------------------------------------------
...
                        self.buf0[(yy+y) % 0xFF][(xx+x) % 0xFF] = COLOR
                else: # Draw body
                    self.buf0[(yy+y) % 0xFF][xx % 0xFF] = COLOR
                    for x in range(constants.COLS):
                        self.buf0[(yy+y) % 0xFF][(xx+x) % 0xFF] &= self.color
                    self.buf0[(yy+y) % 0xFF][(xx + constants.COLS) % 0xFF] = COLOR
                                            ^
------------------------------------------------------------

pyboy/plugins/debug.py:560:44: Compiler crash in AnalyseExpressionsTransform

https://github.com/Baekalfen/PyBoy/actions/runs/6552514964/job/17795971017

It looks like this on Python 3.10:

Compiler crash traceback from this point on:
  File "d:\a\pyboy\pyboy\.eggs\cython-3.0.4-py3.8.egg\Cython\Compiler\ExprNodes.py", line 4968, in analyse_types
    performance_hint(index.pos, "Index should be typed for more efficient access")
TypeError: performance_hint() missing 1 required positional argument: 'env'

Code to reproduce the behaviour:

https://github.com/baekalfen/pyboy

Expected behaviour

Seemingly all other versions work. Expectantly 0.29 through 3.0.3

OS

Linux, Windows, macOS

Python version

3.8, 3.9, 3.10, 3,11

Cython version

3.0.4

Additional context

No response

@gmc444-b
Copy link

gmc444-b commented Oct 19, 2023

I'm able to produce this error with Cython 3.0.3 or 3.0.4 using Python 3.9 and building the package fastavro v 1.3.4 on both RHEL and Ubuntu. To reproduce in a 3.9 venv that has Cython 3.0.4 installed in it:

FASTAVRO_USE_CYTHON=1 pip install --no-binary fastavro fastavro==1.3.4 

I've provided a gist of the output here.

@shakfu
Copy link

shakfu commented Oct 22, 2023

I have a similar failure: on cython3.04 python3.11 running on macOS arm64. I have no error if I revert to prior versions of cython:

Error compiling Cython file:
------------------------------------------------------------
...
        """get samples as a memoryview"""
        self.s_buffer = cvarray(
            shape=(self.n_samples,), itemsize=sizeof(double), format="d")
        self.locksamples()
        for i in range(self.n_samples):
            self.s_buffer[i] = self.samples[i]
                         ^
------------------------------------------------------------

source/projects/py/api.pyx:474:25: Compiler crash in AnalyseExpressionsTransform

ModuleNode.body = StatListNode(api.pyx:105:0)
StatListNode.stats[13] = StatListNode(api.pyx:341:5)
StatListNode.stats[0] = CClassDefNode(api.pyx:341:5,
    as_name = 'Buffer',
    class_name = 'Buffer',
    doc = 'A wrapper class for a Max t_buffer_obj\n    ',
    module_name = '',
    punycode_class_name = 'Buffer',
    visibility = 'private')
CClassDefNode.body = StatListNode(api.pyx:342:4)
StatListNode.stats[25] = DefNode(api.pyx:468:4,
    doc = 'get samples as a memoryview',
    is_cyfunction = True,
    modifiers = [...]/0,
    name = 'get_samples',
    np_args_idx = [...]/0,
    num_required_args = 1,
    outer_attrs = [...]/2,
    py_wrapper_required = True,
    reqd_kw_flags_cname = '0',
    used = True)
File 'Nodes.py', line 397, in analyse_expressions: StatListNode(api.pyx:469:8,
    is_terminator = True)
File 'Nodes.py', line 7556, in analyse_expressions: ForInStatNode(api.pyx:473:8)
File 'Nodes.py', line 397, in analyse_expressions: StatListNode(api.pyx:474:43)
File 'Nodes.py', line 6026, in analyse_expressions: SingleAssignmentNode(api.pyx:474:43)
File 'Nodes.py', line 6164, in analyse_types: SingleAssignmentNode(api.pyx:474:43)
File 'ExprNodes.py', line 4085, in analyse_target_types: IndexNode(api.pyx:474:25,
    is_subscript = True,
    result_is_used = True,
    use_managed_ref = True)
File 'ExprNodes.py', line 4123, in analyse_base_and_index_types: IndexNode(api.pyx:474:25,
    is_subscript = True,
    result_is_used = True,
    use_managed_ref = True)
File 'ExprNodes.py', line 4349, in analyse_as_buffer_operation: IndexNode(api.pyx:474:25,
    is_subscript = True,
    result_is_used = True,
    use_managed_ref = True)
File 'ExprNodes.py', line 4968, in analyse_types: MemoryViewIndexNode(api.pyx:474:25,
    is_memview_index = True,
    memslice_index = True,
    result_is_used = True,
    use_managed_ref = True,
    writable_needed = True)

Compiler crash traceback from this point on:
  File "/opt/homebrew/lib/python3.11/site-packages/Cython/Compiler/ExprNodes.py", line 4968, in analyse_types
    performance_hint(index.pos, "Index should be typed for more efficient access")
TypeError: performance_hint() missing 1 required positional argument: 'env'
make: *** [compile-extension] Error 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants