Skip to content

[BUG] Assertion error from encode_single_position, #6366

Closed
@oscarbenjamin

Description

@oscarbenjamin

Describe the bug

Currently python-flint has a CI job that tests against Cython master branch to measure coverage (gh-6341). That job was passing but has recently (today?) started failing.

Code to reproduce the behaviour:

I don't have a simple reproducer but here is the error message:

[34/111] Compiling Cython source /home/runner/work/python-flint/python-flint/src/flint/types/nmod.pyx
FAILED: src/flint/types/nmod.cpython-312-x86_64-linux-gnu.so.p/src/flint/types/nmod.pyx.c 
cython -M --fast-fail -3 -X embedsignature=True -X emit_code_comments=True -X linetrace=True /home/runner/work/python-flint/python-flint/src/flint/types/nmod.pyx -o src/flint/types/nmod.cpython-312-x86_64-linux-gnu.so.p/src/flint/types/nmod.pyx.c
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.5/x64/bin/cython", line 8, in <module>
    sys.exit(setuptools_main())
             ^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/Cython/Compiler/Main.py", line [74](https://github.com/flintlib/python-flint/actions/runs/10567756039/job/29278457452?pr=179#step:8:75)9, in setuptools_main
    return main(command_line = 1)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/Cython/Compiler/Main.py", line 772, in main
    result = compile(sources, options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/Cython/Compiler/Main.py", line 668, in compile
    return compile_multiple(source, options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/Cython/Compiler/Main.py", line 642, in compile_multiple
    result = run_pipeline(source, options,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/Cython/Compiler/Main.py", line 529, in run_pipeline
    err, enddata = Pipeline.run_pipeline(pipeline, source)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/Cython/Compiler/Pipeline.py", line 404, in run_pipeline
    data = run(phase, data)
           ^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/Cython/Compiler/Pipeline.py", line 386, in run
    return phase(data)
           ^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/Cython/Compiler/Pipeline.py", line 50, in generate_pyx_code_stage
    module_node.process_implementation(options, result)
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/Cython/Compiler/ModuleNode.py", line 226, in process_implementation
    self.generate_c_code(env, options, result)
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/Cython/Compiler/ModuleNode.py", line 548, in generate_c_code
    globalstate.finalize_main_c_code()
  File "Cython/Compiler/Code.py", line 1464, in Cython.Compiler.Code.GlobalState.finalize_main_c_code
  File "Cython/Compiler/Code.py", line 1495, in Cython.Compiler.Code.GlobalState.close_global_decls
  File "Cython/Compiler/Code.py", line 1727, in Cython.Compiler.Code.GlobalState.generate_const_declarations
  File "Cython/Compiler/Code.py", line 2005, in Cython.Compiler.Code.GlobalState.generate_codeobject_constants
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/Cython/Compiler/ExprNodes.py", line 10259, in generate_codeobj
    line_table = StringEncoding.bytes_literal(build_line_table(func.node_positions, first_lineno).encode('iso8[85](https://github.com/flintlib/python-flint/actions/runs/10567756039/job/29278457452?pr=179#step:8:86)9-1'), 'iso8859-1')
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "Cython/Compiler/LineTable.py", line 16, in Cython.Compiler.LineTable.build_line_table
  File "Cython/Compiler/LineTable.py", line 39, in Cython.Compiler.LineTable.encode_single_position
AssertionError: 38 >= 39

Note that I am editing this source file so this might not be triggered by a very new change in Cython but this is only seen with Cython master branch and not with latest released Cython

Expected behaviour

No response

OS

No response

Python version

No response

Cython version

No response

Additional context

https://github.com/flintlib/python-flint/actions/runs/10567756039/job/29278457452?pr=179

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions