diff options
author | Christian Tismer <tismer@stackless.com> | 2017-11-21 17:03:41 +0100 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2017-11-23 00:57:38 +0000 |
commit | 2663162c9038a1151076b7efd3ae53e48e3818df (patch) | |
tree | d19db4935fe6e9ec9c6ceeb2754becf2b5c4b9de | |
parent | 17f9e415bd1a4d4c5c0d86fc2855e92f698842b7 (diff) |
Investigate the sporadic segfaults on RHEL
Lately, the RHEL platform tends to segfault between 0-4 times
in a test run.
I suspect that is related to some finalization code that is triggered
at a special time, due to a stressy situation. But we don't know
until we ask the CI system by printing a stack trace.
This patch prints a stack dump after a segfault happened.
The dump is only activated when the environment setting
QTEST_ENVIRONMENT=ci
is true. (The above needs to be compared with strcmp or strstr)
Note that the tests _are not isolated_. I recognized that by the warnings
module that leaked between tests. The processes are shared, unless
you have setup and teardown functions.
There might for instance be some hidden refcount bug that triggers
only early enough in a stress situation.
Change-Id: Ibbc592e7bdcbdd3cdbc06f203be3e5fc1daaf774
Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r-- | sources/shiboken2/libshiboken/signature.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sources/shiboken2/libshiboken/signature.cpp b/sources/shiboken2/libshiboken/signature.cpp index 883ef7392..fa083111e 100644 --- a/sources/shiboken2/libshiboken/signature.cpp +++ b/sources/shiboken2/libshiboken/signature.cpp @@ -442,6 +442,32 @@ static PyGetSetDef new_PyType_getsets[] = { // This special Type_Ready does certain initializations earlier with // our new version. // + +#ifndef _WIN32 +//////////////////////////////////////////////////////////////////////////// +// a stack trace for linux-like platforms +#include <stdio.h> +#include <execinfo.h> +#include <signal.h> +#include <stdlib.h> +#include <unistd.h> + +void handler(int sig) { + void *array[30]; + size_t size; + + // get void*'s for all entries on the stack + size = backtrace(array, 30); + + // print out all the frames to stderr + fprintf(stderr, "Error: signal %d:\n", sig); + backtrace_symbols_fd(array, size, STDERR_FILENO); + exit(1); +} + +//////////////////////////////////////////////////////////////////////////// +#endif // _WIN32 + static int PySideType_Ready(PyTypeObject *type) { @@ -461,6 +487,12 @@ PySideType_Ready(PyTypeObject *type) || add_more_getsets(&PyStaticMethod_Type, new_PyStaticMethod_getsets) < 0 || add_more_getsets(&PyType_Type, new_PyType_getsets) < 0) return -1; +#ifndef _WIN32 + // we enable the stack trace in CI, only. + const char *testEnv = getenv("QTEST_ENVIRONMENT"); + if (testEnv && strstr(testEnv, "ci")) + signal(SIGSEGV, handler); // install our handler +#endif // _WIN32 init_done = 1; } return PyType_Ready(type); |