# HG changeset patch # User Markus Mützel # Date 1576972887 -3600 # Node ID ec0690a6955c8d5236b29b975c09a1f2a5a1559c # Parent 56dd7419d7aa197340040f914d8ea69aa948710e 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"). diff -r 56dd7419d7aa -r ec0690a6955c libinterp/dldfcn/amd.cc --- 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); diff -r 56dd7419d7aa -r ec0690a6955c libinterp/dldfcn/symbfact.cc --- a/libinterp/dldfcn/symbfact.cc Tue Dec 24 04:01:33 2019 +0100 +++ b/libinterp/dldfcn/symbfact.cc Sun Dec 22 01:01:27 2019 +0100 @@ -43,10 +43,11 @@ #include "error.h" #include "errwarn.h" #include "ovl.h" +#include "parse.h" #include "utils.h" -DEFUN_DLD (symbfact, args, nargout, - doc: /* -*- texinfo -*- +DEFMETHOD_DLD (symbfact, interp, args, nargout, + doc: /* -*- texinfo -*- @deftypefn {} {[@var{count}, @var{h}, @var{parent}, @var{post}, @var{R}] =} symbfact (@var{S}) @deftypefnx {} {[@dots{}] =} symbfact (@var{S}, @var{typ}) @deftypefnx {} {[@dots{}] =} symbfact (@var{S}, @var{typ}, @var{mode}) @@ -209,6 +210,9 @@ cholmod_common *cm = &Common; CHOLMOD_NAME(start) (cm); + // Lock the function to not loose the SuiteSparse_config structure + interp.mlock (); + double spu = octave_sparse_params::get_key ("spumoni"); if (spu == 0.0) {