Mercurial > octave
comparison 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 |
comparison
equal
deleted
inserted
replaced
27868:56dd7419d7aa | 27940:ec0690a6955c |
---|---|
39 #include "error.h" | 39 #include "error.h" |
40 #include "errwarn.h" | 40 #include "errwarn.h" |
41 #include "oct-map.h" | 41 #include "oct-map.h" |
42 #include "ov.h" | 42 #include "ov.h" |
43 #include "ovl.h" | 43 #include "ovl.h" |
44 | 44 #include "parse.h" |
45 DEFUN_DLD (amd, args, nargout, | 45 |
46 doc: /* -*- texinfo -*- | 46 DEFMETHOD_DLD (amd, interp, args, nargout, |
47 doc: /* -*- texinfo -*- | |
47 @deftypefn {} {@var{p} =} amd (@var{S}) | 48 @deftypefn {} {@var{p} =} amd (@var{S}) |
48 @deftypefnx {} {@var{p} =} amd (@var{S}, @var{opts}) | 49 @deftypefnx {} {@var{p} =} amd (@var{S}, @var{opts}) |
49 | 50 |
50 Return the approximate minimum degree permutation of a matrix. | 51 Return the approximate minimum degree permutation of a matrix. |
51 | 52 |
141 | 142 |
142 OCTAVE_LOCAL_BUFFER (octave::suitesparse_integer, P, n_col); | 143 OCTAVE_LOCAL_BUFFER (octave::suitesparse_integer, P, n_col); |
143 Matrix xinfo (AMD_INFO, 1); | 144 Matrix xinfo (AMD_INFO, 1); |
144 double *Info = xinfo.fortran_vec (); | 145 double *Info = xinfo.fortran_vec (); |
145 | 146 |
147 // Lock the function to not loose the SuiteSparse_config structure | |
148 interp.mlock (); | |
149 | |
146 // FIXME: how can we manage the memory allocation of amd | 150 // FIXME: how can we manage the memory allocation of amd |
147 // in a cleaner manner? | 151 // in a cleaner manner? |
148 SUITESPARSE_ASSIGN_FPTR (malloc_func, amd_malloc, malloc); | 152 SUITESPARSE_ASSIGN_FPTR (malloc_func, amd_malloc, malloc); |
149 SUITESPARSE_ASSIGN_FPTR (free_func, amd_free, free); | 153 SUITESPARSE_ASSIGN_FPTR (free_func, amd_free, free); |
150 SUITESPARSE_ASSIGN_FPTR (calloc_func, amd_calloc, calloc); | 154 SUITESPARSE_ASSIGN_FPTR (calloc_func, amd_calloc, calloc); |