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

Wrappers for non-void methods fail to compile with release_GIL_and_enable_signal = True #44

Open
krivenko opened this issue Mar 1, 2022 · 0 comments

Comments

@krivenko
Copy link
Contributor

krivenko commented Mar 1, 2022

When release_GIL_and_enable_signal is switched on, the result object is created inside a nested try block (line 547 of wrap.cxx). Later, it is assumed to be visible in the enclosing scope of that try (line 563).

cpp2py/cpp2py/mako/wrap.cxx

Lines 539 to 570 in a54c236

try {
${overload._get_calling_pattern1()}
%if overload.release_GIL_and_enable_signal :
PyOS_sighandler_t sig = PyOS_getsig(SIGINT);
cpp2py::signal_handler::start(); // start the C++ signal handler
Py_BEGIN_ALLOW_THREADS;
try {
%endif
${overload._get_calling_pattern()}; // the call is here. It sets up "result" : sets up in the python layer.
%if overload.release_GIL_and_enable_signal :
}
catch(...) {
// an error has occurred : clean GIL, handler and rethrow
Py_BLOCK_THREADS; // cf python include, ceval.h, line 72 comments and below.
cpp2py::signal_handler::stop(); // stop the C++ signal handler
PyOS_setsig(SIGINT, sig);
throw; //
}
Py_END_ALLOW_THREADS;
cpp2py::signal_handler::stop();
PyOS_setsig(SIGINT, sig);
%endif
%if not overload.is_constructor :
%if overload.rtype != "void" :
py_result = convert_to_python(std::move(result));
%else:
Py_INCREF(Py_None);
py_result = Py_None;
%endif
%endif
return ${'py_result' if not py_meth.is_constructor else '0'};
}

I wanted to prepare a minimal example based on an existing wrapping unit test, but those seem to have been disabled in both TRIQS unstable and cpp2py.

krivenko added a commit to krivenko/som that referenced this issue Mar 7, 2022
This method computes the final solution using the consistent
constraints approach as described in Section II.B of
O. Goulko et al. Phys. Rev. B 95, 014102 (2017).

The new method is also exposed in Python, although I could not mark it
as `release_GIL_and_enable_signal = True` because of cpp2py issue
TRIQS/cpp2py#44.
krivenko added a commit to krivenko/som that referenced this issue Mar 7, 2022
This method computes the final solution using the consistent
constraints approach as described in Section II.B of
O. Goulko et al. Phys. Rev. B 95, 014102 (2017).

The new method is also exposed in Python, although I could not mark it
as `release_GIL_and_enable_signal = True` because of cpp2py issue
TRIQS/cpp2py#44.
krivenko added a commit to krivenko/som that referenced this issue Mar 8, 2022
This method computes the final solution using the consistent
constraints approach as described in Section II.B of
O. Goulko et al. Phys. Rev. B 95, 014102 (2017).

The new method is also exposed in Python, although I could not mark it
as `release_GIL_and_enable_signal = True` because of cpp2py issue
TRIQS/cpp2py#44.
krivenko added a commit to krivenko/som that referenced this issue Mar 9, 2022
This method computes the final solution using the consistent
constraints approach as described in Section II.B of
O. Goulko et al. Phys. Rev. B 95, 014102 (2017).

The new method is also exposed in Python, although I could not mark it
as `release_GIL_and_enable_signal = True` because of cpp2py issue
TRIQS/cpp2py#44.
krivenko added a commit to krivenko/som that referenced this issue Mar 17, 2022
This method computes the final solution using the consistent
constraints approach as described in Section II.B of
O. Goulko et al. Phys. Rev. B 95, 014102 (2017).

The new method is also exposed in Python, although I could not mark it
as `release_GIL_and_enable_signal = True` because of cpp2py issue
TRIQS/cpp2py#44.
krivenko added a commit to krivenko/som that referenced this issue Mar 18, 2022
This method computes the final solution using the consistent
constraints approach as described in Section II.B of
O. Goulko et al. Phys. Rev. B 95, 014102 (2017).

The new method is also exposed in Python, although I could not mark it
as `release_GIL_and_enable_signal = True` because of cpp2py issue
TRIQS/cpp2py#44.
krivenko added a commit to krivenko/som that referenced this issue May 18, 2022
This method computes the final solution using the consistent
constraints approach as described in Section II.B of
O. Goulko et al. Phys. Rev. B 95, 014102 (2017).

The new method is also exposed in Python, although I could not mark it
as `release_GIL_and_enable_signal = True` because of cpp2py issue
TRIQS/cpp2py#44.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant