*/}}
Browse Source

SIGSEGV handler

YimingWu 1 year ago
parent
commit
2b2525084f
2 changed files with 15 additions and 0 deletions
  1. 14 0
      la_kernel.c
  2. 1 0
      resources/la_operators.c

+ 14 - 0
la_kernel.c

@@ -22,7 +22,10 @@
 #include <stdlib.h>
 #include <math.h>
 #include <time.h>
+
 #ifdef __linux__
+#include <execinfo.h>
+#include <signal.h>
 #include <sys/time.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
@@ -378,6 +381,15 @@ void la_DestroySystemWindowWin32(laWindow* w) {
 };
 #endif
 
+void la_HandlerSIGSEGV(int sig) {
+    void *array[30];
+    size_t sz;
+    sz = backtrace(array, 30);
+
+    fprintf(stdout, "LaGUI recieved error signal %d:\n The program terminated unexpectedly.\n", sig);
+    backtrace_symbols_fd(array, sz, STDERR_FILENO);
+    exit(1);
+}
 
 void la_glDebugOutput(GLenum source, GLenum type, unsigned int id,
     GLenum severity, GLsizei length, const char* message, const void* userParam) {
@@ -805,6 +817,8 @@ void laProcessInitArguments(int argc, char* argv[],laInitArguments* ia) {
     }
 }
 int laGetReadyWith(laInitArguments* ia){
+    signal(SIGSEGV,la_HandlerSIGSEGV);
+
     memcpy(&MAIN.InitArgs,ia,sizeof(laInitArguments));
     if(MAIN.InitArgs.GLMajor>4||MAIN.InitArgs.GLMajor<1){ MAIN.InitArgs.GLMajor=3; }
     if(MAIN.InitArgs.GLMinor<1){ MAIN.InitArgs.GLMinor=3; }

+ 1 - 0
resources/la_operators.c

@@ -771,6 +771,7 @@ int OPCHK_CollectionSetValue(laPropPack *This, laStringSplitor *Instructions){
 int OPINV_CollectionClearSelection(laOperator *a, laEvent *e){
     if(!a->This) return LA_CANCELED; laSubProp* sp=a->This->LastPs->p;
     laSetActiveInstance(sp, a->This->LastPs->UseInstance, 0);
+    return LA_FINISHED;
 }
 int OPINV_PropSetDefault(laOperator *a, laEvent *e){
     if(!a->This) return LA_CANCELED; laProp* p=a->This->LastPs->p;