diff libinterp/dldfcn/amd.cc @ 27940:ec0690a6955c stable rc-5-1-90

Lock amd and symbfact to avoid segmentation fault with SuiteSparse (bug #57435). * dldfcn/amd.cc (Famd), dldfcn/symbfact.cc (Fsymbfact): Use DEFMETHOD_DLD. Call "mlock" to avoid having invalid function pointers in global SuiteSparse_config structure when the functions are unloaded (e.g. with "clear functions").
author Markus Mützel <markus.muetzel@gmx.de>
date Sun, 22 Dec 2019 01:01:27 +0100
parents c0d8ce61c1c9
children b442ec6dda5c
line wrap: on
line diff
--- a/libinterp/dldfcn/amd.cc	Tue Dec 24 04:01:33 2019 +0100
+++ b/libinterp/dldfcn/amd.cc	Sun Dec 22 01:01:27 2019 +0100
@@ -41,9 +41,10 @@
 #include "oct-map.h"
 #include "ov.h"
 #include "ovl.h"
+#include "parse.h"
 
-DEFUN_DLD (amd, args, nargout,
-           doc: /* -*- texinfo -*-
+DEFMETHOD_DLD (amd, interp, args, nargout,
+               doc: /* -*- texinfo -*-
 @deftypefn  {} {@var{p} =} amd (@var{S})
 @deftypefnx {} {@var{p} =} amd (@var{S}, @var{opts})
 
@@ -143,6 +144,9 @@
   Matrix xinfo (AMD_INFO, 1);
   double *Info = xinfo.fortran_vec ();
 
+  // Lock the function to not loose the SuiteSparse_config structure
+  interp.mlock ();
+
   // FIXME: how can we manage the memory allocation of amd
   //        in a cleaner manner?
   SUITESPARSE_ASSIGN_FPTR (malloc_func, amd_malloc, malloc);