Merge pull request #36449 from xsellier/fix-late-segfault-hang

[2.1] Fixed hang when segfaulting after OS object destroyed (OSX and X11)
This commit is contained in:
Rémi Verschelde 2020-02-22 16:58:01 +01:00 committed by GitHub
commit ce57492e8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View File

@ -27,13 +27,13 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "main/main.h"
#include "os_osx.h"
#include <string.h>
#include <unistd.h>
// Note: Dump backtrace in 32bit mode is getting a bus error on the fgets by the ->execute, so enable only on 64bit
#if defined(DEBUG_ENABLED) && defined(__x86_64__)
#define CRASH_HANDLER_ENABLED 1
#endif
@ -72,8 +72,9 @@ static uint32_t load_address() {
}
static void handle_crash(int sig) {
if (OS::get_singleton() == NULL || Globals::get_singleton() == NULL)
return;
if (OS::get_singleton() == NULL) {
abort();
}
void *bt_buffer[256];
size_t size = backtrace(bt_buffer, 256);
@ -82,6 +83,7 @@ static void handle_crash(int sig) {
// Dump the backtrace to stderr with a message to the user
fprintf(stderr, "%s: Program crashed with signal %d\n", __FUNCTION__, sig);
fprintf(stderr, "Dumping the backtrace. %ls\n", msg.c_str());
char **strings = backtrace_symbols(bt_buffer, size);
if (strings) {
@ -155,6 +157,7 @@ CrashHandler::CrashHandler() {
}
CrashHandler::~CrashHandler() {
disable();
}
void CrashHandler::disable() {

View File

@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifdef DEBUG_ENABLED
#define CRASH_HANDLER_ENABLED 1
#endif
@ -42,8 +43,9 @@
#include <stdlib.h>
static void handle_crash(int sig) {
if (OS::get_singleton() == NULL || Globals::get_singleton() == NULL)
return;
if (OS::get_singleton() == NULL) {
abort();
}
void *bt_buffer[256];
size_t size = backtrace(bt_buffer, 256);
@ -52,6 +54,7 @@ static void handle_crash(int sig) {
// Dump the backtrace to stderr with a message to the user
fprintf(stderr, "%s: Program crashed with signal %d\n", __FUNCTION__, sig);
fprintf(stderr, "Dumping the backtrace. %ls\n", msg.c_str());
char **strings = backtrace_symbols(bt_buffer, size);
if (strings) {
@ -112,6 +115,7 @@ CrashHandler::CrashHandler() {
}
CrashHandler::~CrashHandler() {
disable();
}
void CrashHandler::disable() {