Commit 7747b4b2 authored by Kevin Modzelewski's avatar Kevin Modzelewski

We're failing some tests in CI due to recursion depth issues

Which are quite hard to reproduce because they depend on the details
of the C stack.

Anyway, we should probably start using the recursion-depth-tracking functions
in more place, rather than getting segfaults.  There are a lot of CPython tests
that test for recursion-depth-checking.
parent 526a0fc0
......@@ -1116,6 +1116,22 @@ public:
operator FILE*() const { return file; }
};
void throwCAPIException();
// A C++-style RAII way of doing Py_EnterRecursiveCall + Py_LeaveRecursiveCall
class _RecursiveBlockHelper {
public:
~_RecursiveBlockHelper() { Py_LeaveRecursiveCall(); }
};
#define RECURSIVE_BLOCK(S, reason) \
_RecursiveBlockHelper CAT(_recursive_helper, __LINE__); \
if (Py_EnterRecursiveCall(reason)) { \
if (S == CAPI) \
return NULL; \
else \
throwCAPIException(); \
}
// similar to Java's Array.binarySearch:
// return values are either:
// >= 0 : the index where a given item was found
......
......@@ -539,7 +539,7 @@ extern "C" int Py_FlushLine(void) noexcept {
return PyFile_WriteString("\n", f);
}
void setCAPIException(STOLEN(const ExcInfo&) e) {
void setCAPIException(STOLEN(const ExcInfo&) e) noexcept {
PyErr_Restore(e.type, e.value, e.traceback);
}
......
......@@ -4747,6 +4747,9 @@ Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpe
template <ExceptionStyle S>
static Box* callChosenCF(CompiledFunction* chosen_cf, BoxedClosure* closure, BoxedGenerator* generator, Box* globals,
Box* oarg1, Box* oarg2, Box* oarg3, Box** oargs) noexcept(S == CAPI) {
// TODO: this should be done in the rewrite as well
RECURSIVE_BLOCK(S, " in function call");
if (S != chosen_cf->exception_style) {
if (S == CAPI) {
try {
......
......@@ -169,7 +169,7 @@ void checkAndThrowCAPIException();
void throwCAPIException() __attribute__((noreturn));
void ensureCAPIExceptionSet();
struct ExcInfo;
void setCAPIException(STOLEN(const ExcInfo&) e);
void setCAPIException(STOLEN(const ExcInfo&) e) noexcept;
// Finalizer-related
void dealloc_null(Box* box);
......
......@@ -172,7 +172,7 @@ test_unicode argument passing issue?
test_userdict segfault: repr of recursive dict?
test_userlist slice(1L, 1L)
test_userstring float(1L); hangs in test_replace
test_warnings [unknown]
test_warnings Among other things, we don't support the -W flag
test_weakref weird function-picking bug (something around float.__add__), plase also fix the weakref issue in test_abc
test_winreg [unknown]
test_winsound [unknown]
......
../../from_cpython/Lib/test/warning_tests.py
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment