Changeset: 3a85c43261f0 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3a85c43261f0
Modified Files:
        testing/Mtest.py.in
Branch: Dec2016
Log Message:

Try to get core dump info when program crashes.


diffs (65 lines):

diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -55,6 +55,23 @@ else:
     # no coloring if not to a tty
     RED = GREEN = PURPLE = BLACK = ''
 
+if os.path.exists('/usr/bin/coredumpctl'):
+    # probably Linux if /usr/bin/coredumpctl exists
+    # try raising the core dump size limit to infinite so that when we
+    # get a crash we have a chance to retrieve the stack trace
+    try:
+        import resource
+    except ImportError:
+        pass
+    else:
+        try:
+            resource.setrlimit(resource.RLIMIT_CORE,
+                               (resource.RLIM_INFINITY,
+                                resource.getrlimit(resource.RLIMIT_CORE)[1]))
+        except ValueError:
+            # if we can't raise the limit, just forget it
+            pass
+
 def ErrExit(msg):
     sys.stderr.write(msg + '\n')
     sys.exit(1)
@@ -1527,6 +1544,18 @@ def returnCode(proc, f = None):
         if proc.returncode == -signal.SIGSEGV:
             if f is not None:
                 f.write('\nSegmentation fault\n')
+                if os.path.exists('/usr/bin/coredumpctl'):
+                    # wait a few seconds for the core to be dumped
+                    time.sleep(10)
+                    if procdebug:
+                        print('Starting: coredumpctl info %d' % proc.pid)
+                    p = process.Popen(['coredumpctl', 'info', str(proc.pid)],
+                                      stdout = process.PIPE,
+                                      stderr = process.PIPE,
+                                      universal_newlines = True)
+                    out, err = p.communicate()
+                    if not err and out:
+                        f.write(out)
                 f.flush()
             return 'segfault'   # Segmentation fault
         if proc.returncode == -signal.SIGBUS:
@@ -1537,6 +1566,18 @@ def returnCode(proc, f = None):
         if proc.returncode == -signal.SIGABRT:
             if f is not None:
                 f.write('\nAborted\n')
+                if os.path.exists('/usr/bin/coredumpctl'):
+                    # wait a few seconds for the core to be dumped
+                    time.sleep(10)
+                    if procdebug:
+                        print('Starting: coredumpctl info %d' % proc.pid)
+                    p = process.Popen(['coredumpctl', 'info', str(proc.pid)],
+                                      stdout = process.PIPE,
+                                      stderr = process.PIPE,
+                                      universal_newlines = True)
+                    out, err = p.communicate()
+                    if not err and out:
+                        f.write(out)
                 f.flush()
             return 'abort'      # Aborted
         if proc.returncode == -signal.SIGINT:
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to