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

invalid conversion from ‘void*’ to ‘_PyCodeArray*’ found in internal headers when compiling with Python 3.14t #127411

Closed
clin1234 opened this issue Nov 29, 2024 · 4 comments
Labels
3.14 new features, bugs and security fixes build The build process and cross-build topic-free-threading type-bug An unexpected behavior, bug, or error

Comments

@clin1234
Copy link

clin1234 commented Nov 29, 2024

Bug report

Bug description:

Cross-reporting from scipy/scipy#21968 scipy/scipy#21970

Installing scipy from git with the free-threaded interpreter yielded the following errors:

[65/1464] Compiling C++ object scipy/special/_specfun.cpython-314t-x86_64-linux-gnu.so.p/meson-generated__specfun.cpp.o
      FAILED: scipy/special/_specfun.cpython-314t-x86_64-linux-gnu.so.p/meson-generated__specfun.cpp.o
      c++ -Iscipy/special/_specfun.cpython-314t-x86_64-linux-gnu.so.p -Iscipy/special -I../scipy/special -I../../../workspaces/venv/lib/python3.14t/site-packages/numpy/_core/include -I/usr/include/python3.14t -fvisibility=hidden -fvisibility-inlines-hidden -fdiagnostics-color=always -DNDEBUG -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c++17 -O3 -fPIC -DNPY_NO_DEPRECATED_API=NPY_1_9_API_VERSION -MD -MQ scipy/special/_specfun.cpython-314t-x86_64-linux-gnu.so.p/meson-generated__specfun.cpp.o -MF scipy/special/_specfun.cpython-314t-x86_64-linux-gnu.so.p/meson-generated__specfun.cpp.o.d -o scipy/special/_specfun.cpython-314t-x86_64-linux-gnu.so.p/meson-generated__specfun.cpp.o -c scipy/special/_specfun.cpython-314t-x86_64-linux-gnu.so.p/_specfun.cpp
      In file included from /usr/include/python3.14t/internal/pycore_frame.h:13,
                       from scipy/special/_specfun.cpython-314t-x86_64-linux-gnu.so.p/_specfun.cpp:12385:
      /usr/include/python3.14t/internal/pycore_code.h: In function ‘_Py_CODEUNIT* _PyCode_GetTLBCFast(PyThreadState*, PyCodeObject*)’:
      /usr/include/python3.14t/internal/pycore_code.h:617:53: error: invalid conversion from ‘void*’ to ‘_PyCodeArray*’ [-fpermissive]
        617 |     _PyCodeArray *code = _Py_atomic_load_ptr_acquire(&co->co_tlbc);
            |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
            |                                                     |
            |                                                     void*
      In file included from scipy/special/_specfun.cpython-314t-x86_64-linux-gnu.so.p/_specfun.cpp:12385:
      /usr/include/python3.14t/internal/pycore_frame.h: In function ‘_Py_CODEUNIT* _PyFrame_GetBytecode(_PyInterpreterFrame*)’:
      /usr/include/python3.14t/internal/pycore_frame.h:96:53: error: invalid conversion from ‘void*’ to ‘_PyCodeArray*’ [-fpermissive]
         96 |     _PyCodeArray *tlbc = _Py_atomic_load_ptr_acquire(&co->co_tlbc);
            |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
            |                                                     |
            |                                                     void*
      [66/1464] Compiling C++ object scipy/special/_gufuncs.cpython-314t-x86_64-linux-gnu.so.p/_gufuncs.cpp.o
      [67/1464] Compiling C++ object scipy/special/_special_ufuncs.cpython-314t-x86_64-linux-gnu.so.p/_special_ufuncs.cpp.o
      ninja: build stopped: subcommand failed.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs

@colesbury
Copy link
Contributor

The header is C code, not C++, and it is internal only, not a public header.

Please see Ralf's comment on the SciPy issue for compiling SciPy with Cython 3.1.0a1.

@colesbury colesbury closed this as not planned Won't fix, can't repro, duplicate, stale Nov 29, 2024
@colesbury
Copy link
Contributor

colesbury commented Nov 29, 2024

Oh - I think this should be referencing scipy/scipy#21970 instead.

Ralf wrote:

...it looks like it's Cython digging into CPython private internals, which have probably just changed. That tends to break regularly...

Yes, the Cython dependencies on CPython internals are a headache every release. I think some of them have been removed; it'd be great if we can remove the remaining deps.

In the meantime, we should just add a cast here so that it compiles in C++ as well.

cc @mpage.

@colesbury colesbury reopened this Nov 29, 2024
@clin1234
Copy link
Author

At a quick glance, a simple cast within the internal header should suffice, since the compilation error isn't pointing to a line within the generated C++ code

@ZeroIntensity ZeroIntensity added build The build process and cross-build 3.14 new features, bugs and security fixes labels Nov 30, 2024
@ZeroIntensity
Copy link
Member

Yeah, the bandaid is to just change it to _Py_CAST(_PyCodeArray*, _Py_atomic_load_ptr_acquire(&co->co_tlbc)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.14 new features, bugs and security fixes build The build process and cross-build topic-free-threading type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

5 participants