21 #ifndef WITH_PYTHON_MODULE
23 # if defined(__linux__) && defined(__GNUC__)
28 # if (defined(__APPLE__) && (defined(__i386__) || defined(__x86_64__)))
30 # include <xmmintrin.h>
52 # include BLI_SYSTEM_PID_H
69 # ifdef USE_WRITE_CRASH_BLEND
75 # if defined(__linux__) || defined(_WIN32) || defined(OSX_SSE_FPE)
76 static void sig_handle_fpe(
int UNUSED(sig))
78 fprintf(stderr,
"debug: SIGFPE trapped\n");
83 # if !defined(WITH_HEADLESS)
92 printf(
"\nBlender killed\n");
95 printf(
"\nSent an internal break event. Press ^C again to kill Blender\n");
103 fputs(
"\n# backtrace\n", fp);
114 # ifdef USE_WRITE_CRASH_BLEND
128 printf(
"Writing: %s\n", fname);
149 printf(
"Writing: %s\n", fname);
170 "Unable to save '%s': %s\n",
172 errno ? strerror(errno) :
"Unknown error opening file");
193 signal(signum, SIG_DFL);
195 kill(getpid(), signum);
197 TerminateProcess(GetCurrentProcess(), signum);
202 extern LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
206 if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_STACK_OVERFLOW) {
208 CHAR modulename[MAX_PATH];
209 LPVOID address = ExceptionInfo->ExceptionRecord->ExceptionAddress;
210 fprintf(stderr,
"Error : EXCEPTION_STACK_OVERFLOW\n");
211 fprintf(stderr,
"Address : 0x%p\n", address);
212 if (GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, address, &
mod)) {
213 if (GetModuleFileName(
mod, modulename, MAX_PATH)) {
214 fprintf(stderr,
"Module : %s\n", modulename);
223 return EXCEPTION_EXECUTE_HANDLER;
237 SetUnhandledExceptionFilter(windows_exception_handler);
246 SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | SEM_NOGPFAULTERRORBOX |
247 SEM_NOOPENFILEERRORBOX);
260 # if !defined(WITH_HEADLESS)
267 # if defined(__linux__) || defined(_WIN32) || defined(OSX_SSE_FPE)
270 signal(SIGFPE, sig_handle_fpe);
272 # if defined(__linux__) && defined(__GNUC__)
273 feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
275 # if defined(OSX_SSE_FPE)
278 _MM_SET_EXCEPTION_MASK(_MM_MASK_MASK &
279 ~(_MM_MASK_OVERFLOW | _MM_MASK_INVALID | _MM_MASK_DIV_ZERO));
281 # if defined(_WIN32) && defined(_MSC_VER)
283 _controlfp_s(
NULL, 0, _MCW_EM);
285 _controlfp_s(
NULL, _EM_DENORMAL | _EM_UNDERFLOW | _EM_INEXACT, _MCW_EM);
void BKE_tempdir_session_purge(void)
const char * BKE_tempdir_base(void)
bool BKE_report_write_file_fp(FILE *fp, ReportList *reports, const char *header)
File and directory operations.
FILE * BLI_fopen(const char *filename, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
const char * BLI_path_basename(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
void BLI_join_dirfile(char *__restrict dst, const size_t maxlen, const char *__restrict dir, const char *__restrict file) ATTR_NONNULL()
bool BLI_path_extension_replace(char *path, size_t maxlen, const char *ext) ATTR_NONNULL()
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
void BLI_system_backtrace(FILE *fp)
Compatibility-like things for windows.
bool BLO_memfile_write_file(struct MemFile *memfile, const char *filename)
void BPY_python_backtrace(FILE *fp)
struct ApplicationState app_state
#define BLEND_VERSION_ARG
#define BLEND_VERSION_FMT
void main_signal_setup_background(void)
static void sig_handle_abort(int UNUSED(signum))
void main_signal_setup_fpe(void)
static void sig_handle_crash(int signum)
static void sig_handle_blender_esc(int sig)
void main_signal_setup(void)
static void sig_handle_crash_backtrace(FILE *fp)
struct ApplicationState::@1182 signal
struct ReportList reports
struct UndoStack * undo_stack
void BLI_windows_handle_exception(EXCEPTION_POINTERS *exception)
ccl_device_inline int mod(int x, int m)