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

Removal of private C-API breaks uwsgi compilation #121758

Closed
xrmx opened this issue Jul 14, 2024 · 6 comments
Closed

Removal of private C-API breaks uwsgi compilation #121758

xrmx opened this issue Jul 14, 2024 · 6 comments
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes topic-C-API type-bug An unexpected behavior, bug, or error

Comments

@xrmx
Copy link
Contributor

xrmx commented Jul 14, 2024

Bug report

Bug description:

Hello,

while trying to port uwsgi to 3.13 got this:

plugins/python/python_plugin.c: In function ‘uwsgi_python_pre_uwsgi_fork’:
plugins/python/python_plugin.c:1376:17: error: implicit declaration of function ‘_PyImport_AcquireLock’ [-Werror=implicit-function-declaration]
 1376 |                 _PyImport_AcquireLock(interp);
      |                 ^~~~~~~~~~~~~~~~~~~~~
plugins/python/python_plugin.c: In function ‘uwsgi_python_post_uwsgi_fork’:
plugins/python/python_plugin.c:1393:25: error: implicit declaration of function ‘_PyImport_ReleaseLock’ [-Werror=implicit-function-declaration]
 1393 |                         _PyImport_ReleaseLock(interp);
      |                         ^~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Is there any other available API we can use?

I can make it compile by importing the internal header but does not look like a proper solution:

#if (PY_VERSION_HEX >= 0x030d0000)
#include "internal/pycore_import.h"
#endif

WIP branch is here https://github.com/unbit/uwsgi/tree/wip-py-313

cc @vstinner

CPython versions tested on:

3.13

Operating systems tested on:

Linux

@xrmx xrmx added the type-bug An unexpected behavior, bug, or error label Jul 14, 2024
@hugovk hugovk added topic-C-API 3.13 bugs and security fixes 3.14 new features, bugs and security fixes labels Jul 14, 2024
@Eclips4 Eclips4 changed the title Removal of private API breaks uwsgi compilation Removal of private C-API breaks uwsgi compilation Jul 14, 2024
@vstinner
Copy link
Member

vstinner commented Jul 14, 2024

Why calling _PyImport_AcquireLock() in uwsgi_python_pre_uwsgi_fork(), instead of PyOS_BeforeFork()?

By the way, I'm not sure that it's safe to call PyOS_AfterFork_Child() in uwsgi_python_post_uwsgi_fork() without calling PyOS_BeforeFork().

@xrmx
Copy link
Contributor Author

xrmx commented Jul 16, 2024

Why calling _PyImport_AcquireLock() in uwsgi_python_pre_uwsgi_fork(), instead of PyOS_BeforeFork()?

I think the code predates PyOS_BeforeFork by years 😅 and we didn't give it enough attention until it broke.

By the way, I'm not sure that it's safe to call PyOS_AfterFork_Child() in uwsgi_python_post_uwsgi_fork() without calling PyOS_BeforeFork().

Thanks

@vstinner
Copy link
Member

Can you try PyOS_BeforeFork() and tell me how it goes?

@xrmx
Copy link
Contributor Author

xrmx commented Jul 21, 2024

Opened a PR here, CI passes but haven't tested it unbit/uwsgi#2655

@vstinner
Copy link
Member

@xrmx: Since there is now a pending uwsgi PR, is it still useful to have a Python issue? Or can we close this issue?

@xrmx
Copy link
Contributor Author

xrmx commented Aug 27, 2024

Closing, thanks @vstinner !

@xrmx xrmx closed this as completed Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes topic-C-API type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants