在 Ubuntu 14.04 和 matlab 2014Ra 上使用犰狳在 mex 中出现分段错误

Posted

技术标签:

【中文标题】在 Ubuntu 14.04 和 matlab 2014Ra 上使用犰狳在 mex 中出现分段错误【英文标题】:Segmentation fault in mex with armadillo on Ubuntu 14.04 and matlab 2014Ra 【发布时间】:2015-07-30 08:41:24 【问题描述】:

我尝试将 mex 文件与犰狳线性代数库一起使用。一开始,我尝试了一个非常简单的程序,如下:

谁能帮帮我?

%%%% matlab脚本%%%%%%%

mex -larmadillo -lgfortran armaMex_demo.cpp
X = randn(5,5);
Y = randn(5,5);
% Run the demo using X and Y
Z = armaMex_demo(X,Y,3)

%%%%%%%%%%%%% mex 文件 %%%%%%

#include "armaMex.hpp"
#include <armadillo>
using namespace arma;
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
  
  // Check the number of input arguments.
  if (nrhs != 3)
    mexErrMsgTxt("Incorrect number of input arguments.");

  // Check type of input.
  if ( (mxGetClassID(prhs[0]) != mxDOUBLE_CLASS) || (mxGetClassID(prhs[1]) != mxDOUBLE_CLASS) )
    mexErrMsgTxt("Input must me of type double.");

  // Check if input is real.
  if ( (mxIsComplex(prhs[0])) || (mxIsComplex(prhs[1])) )
    mexErrMsgTxt("Input must be real.");

  // Create matrices X and Y from the first and second argument.
  mat X = armaGetPr(prhs[0]);
  mat Y = armaGetPr(prhs[1]);
  int c= armaGetScalar<int>(prhs[2]);  
  // Our calculations require that matrices must be of the same size 
  if ( size(X) != size(Y) )
    mexErrMsgTxt("Matrices should be of same size.");

  // Perform calculations
  mat A = X + Y;
  mat B = X % Y;  // % means element-wise multiplication in Armadillo
  mat D = inv(X)*Y;
  int ee = trace(X.i()*Y) + log(det(X));

  // Create cube C with A and B as slices.
  cube C(A.n_rows, A.n_cols, 4);    
  mat E = zeros<mat>(A.n_rows, A.n_cols);
  E(0,0) = ee;
  C.slice(0) = A;
  C.slice(1) = B;
  C.slice(2) = D;
  C.slice(3) = E;   
  plhs[0] = armaCreateMxMatrix(C.n_rows, C.n_cols, C.n_slices);
  armaSetCubePr(plhs[0], C);
  return;
  

%%%%%%%错误%%%%%%%%%

我试过X,Y的尺寸是3*3, 4*4,没问题 但是当我尝试使用 5*5 的矩阵求逆时,出现了失败 “分段错误(核心转储)”

在matlab界面中

在 2015 年 7 月 30 日星期四 16:04:53 检测到分段违规

Configuration:
  Crash Decoding     : Disabled
  Current Visual     : 0x21 (class 4, depth 24)
  Default Encoding   : UTF-8
  GNU C Library      : 2.19 stable
  MATLAB Architecture: glnxa64
  MATLAB Root        : /usr/local/MATLAB/R2014a
  MATLAB Version     : 8.3.0.532 (R2014a)
  Operating System   : Linux 3.16.0-45-generic #60~14.04.1-Ubuntu SMP Fri Jul 24 21:16:23 UTC 2015 x86_64
  Processor ID       : x86 Family 6 Model 60 Stepping 3, GenuineIntel
  Virtual Machine    : Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
  Window System      : The X.Org Foundation (11600000), display :0

Fault Count: 4


Abnormal termination:
Segmentation violation

Register State (from fault):
  RAX = 0000000000000001  RBX = 0000000300000002
  RCX = 0000000000000000  RDX = 00000000000027f8
  RSP = 00007fd737ff71c0  RBP = 0000000000000000
  RSI = 00007fd737ff9090  RDI = 0000000300000000

   R8 = 0000000000027f40   R9 = 0000000000000002
  R10 = 00007fd737ff9090  R11 = bff0000000000000
  R12 = 0000000000000000  R13 = 0000000000000000
  R14 = 0000003000000030  R15 = 00007fd737ff9090

  RIP = 00007fd68e79ff3b  EFL = 0000000000010202

   CS = 0033   FS = 0000   GS = 0000

Stack Trace (from fault):
[  0] 0x00007fd68e79ff3b        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+15413051 mkl_blas_avx2_izamax+00000779
[  1] 0x00007fd68ddae95f        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+04987231 mkl_lapack_zgetf2+00000255
[  2] 0x00007fd68e1f9f63        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+09490275 mkl_lapack_zgetrf_local+00001459
[  3] 0x00007fd68e1f9c56        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+09489494 mkl_lapack_zgetrf_local+00000678
[  4] 0x00007fd68e1f9c56        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+09489494 mkl_lapack_zgetrf_local+00000678
[  5] 0x00007fd68e1f9c56        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+09489494 mkl_lapack_zgetrf_local+00000678
[  6] 0x00007fd68e1f9c56        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+09489494 mkl_lapack_zgetrf_local+00000678
[  7] 0x00007fd68da771de        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+01614302 mkl_lapack_zgetrf+00003822
[  8] 0x00007fd68dc0ea8b        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+03283595 mkl_lapack_ao_zgetrf+00000107
[  9] 0x00007fd68ddbae0b        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+05037579 mkl_lapack_zgesv+00000187
[ 10] 0x00007fd688d00a7b /home/weiwei/Work/PolSAR/PolSAR/PolSAR_code/mex_SLICPolSAR.mexa64+00105083
[ 11] 0x00007fd688cf9401 /home/weiwei/Work/PolSAR/PolSAR/PolSAR_code/mex_SLICPolSAR.mexa64+00074753
[ 12] 0x00007fd688cf51ca /home/weiwei/Work/PolSAR/PolSAR/PolSAR_code/mex_SLICPolSAR.mexa64+00057802
[ 13] 0x00007fd688cf0eb5 /home/weiwei/Work/PolSAR/PolSAR/PolSAR_code/mex_SLICPolSAR.mexa64+00040629
[ 14] 0x00007fd688cef8cd /home/weiwei/Work/PolSAR/PolSAR/PolSAR_code/mex_SLICPolSAR.mexa64+00035021
[ 15] 0x00007fd688cebb37 /home/weiwei/Work/PolSAR/PolSAR/PolSAR_code/mex_SLICPolSAR.mexa64+00019255
[ 16] 0x00007fd688ced570 /home/weiwei/Work/PolSAR/PolSAR/PolSAR_code/mex_SLICPolSAR.mexa64+00025968 mexFunction+00001660
[ 17] 0x00007fd74647272a     /usr/local/MATLAB/R2014a/bin/glnxa64/libmex.so+00120618 mexRunMexFile+00000090
[ 18] 0x00007fd74646ea94     /usr/local/MATLAB/R2014a/bin/glnxa64/libmex.so+00105108
[ 19] 0x00007fd74646ffb4     /usr/local/MATLAB/R2014a/bin/glnxa64/libmex.so+00110516
[ 20] 0x00007fd745869ad9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_dispatcher.so+00670425 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00000697
[ 21] 0x00007fd744b062b4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04461236
[ 22] 0x00007fd744b07bc9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04467657
[ 23] 0x00007fd744b083fc /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04469756
[ 24] 0x00007fd7449826e3 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02873059
[ 25] 0x00007fd74499209e /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02936990
[ 26] 0x00007fd744992183 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02937219
[ 27] 0x00007fd744ac8172 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04206962
[ 28] 0x00007fd7448fd589 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02327945
[ 29] 0x00007fd744900167 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02339175
[ 30] 0x00007fd7448fe26f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02331247
[ 31] 0x00007fd7448feec4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02334404
[ 32] 0x00007fd74495c30b /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02716427
[ 33] 0x00007fd745869c5f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_dispatcher.so+00670815 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00001087
[ 34] 0x00007fd74494020e /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02601486
[ 35] 0x00007fd7448e11b0 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02212272
[ 36] 0x00007fd7448fc25f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02323039
[ 37] 0x00007fd744900167 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02339175
[ 38] 0x00007fd7448fe26f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02331247
[ 39] 0x00007fd7448feec4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02334404
[ 40] 0x00007fd74495c30b /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02716427
[ 41] 0x00007fd745869c5f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_dispatcher.so+00670815 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00001087
[ 42] 0x00007fd74492f135 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02531637
[ 43] 0x00007fd7448f60d9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02298073
[ 44] 0x00007fd7448f2dc7 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02284999
[ 45] 0x00007fd7448f3193 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02285971
[ 46] 0x00007fd74669cafc /usr/local/MATLAB/R2014a/bin/glnxa64/libmwbridge.so+00142076
[ 47] 0x00007fd74669d791 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwbridge.so+00145297 _Z8mnParserv+00000721
[ 48] 0x00007fd74f95392f   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00489775 _ZN11mcrInstance30mnParser_on_interpreter_threadEv+00000031
[ 49] 0x00007fd74f934b6d   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00363373
[ 50] 0x00007fd74f934be9   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00363497
[ 51] 0x00007fd744028d46   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwuix.so+00343366
[ 52] 0x00007fd74400b382   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwuix.so+00222082
[ 53] 0x00007fd7500a950f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02323727
[ 54] 0x00007fd7500a967c /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02324092
[ 55] 0x00007fd7500a557f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02307455
[ 56] 0x00007fd7500aa9b5 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02329013
[ 57] 0x00007fd7500aade7 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02330087
[ 58] 0x00007fd7500ab4c0 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02331840 _Z25svWS_ProcessPendingEventsiib+00000080
[ 59] 0x00007fd74f935098   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00364696
[ 60] 0x00007fd74f9353bf   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00365503
[ 61] 0x00007fd74f93028f   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00344719
[ 62] 0x00007fd74e8de182              /lib/x86_64-linux-gnu/libpthread.so.0+00033154
[ 63] 0x00007fd74e60b47d                    /lib/x86_64-linux-gnu/libc.so.6+01025149 clone+00000109


Abnormal termination:
Segmentation violation

Register State (from fault):
  RAX = 0000000000000002  RBX = 0000000000000000
  RCX = 0000001000000004  RDX = 000000000024875f
  RSP = 00007fd737ff9538  RBP = 0000000000000000
  RSI = 00007fd6b6ddd500  RDI = 00007fd737ff9500

   R8 = 0000001000000003   R9 = 0000000000000004
  R10 = 0000000000000005  R11 = 00007fd74e698a30
  R12 = 0000000000000000  R13 = 0000001000000005
  R14 = 00007fd6b6ddd500  R15 = 0000000000000000

  RIP = 00007fd68e7a0872  EFL = 0000000000010287

   CS = 0033   FS = 0000   GS = 0000

Stack Trace (from fault):
[  0] 0x00007fd68e7a0872        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+15415410 mkl_blas_avx2_idamax+00000626
[  1] 0x00007fd68e05faae        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07809710 mkl_lapack_dgetf2+00000238
[  2] 0x00007fd68e05f869        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07809129 mkl_lapack_dgetrf_local+00001369
[  3] 0x00007fd68e05f4ae        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07808174 mkl_lapack_dgetrf_local+00000414
[  4] 0x00007fd68e05f4ae        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07808174 mkl_lapack_dgetrf_local+00000414
[  5] 0x00007fd68e05f4ae        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07808174 mkl_lapack_dgetrf_local+00000414
[  6] 0x00007fd68e05f4ae        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07808174 mkl_lapack_dgetrf_local+00000414
[  7] 0x00007fd68dab6562        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+01873250 mkl_lapack_dgetrf+00003810
[  8] 0x00007fd66cf48a74 /home/weiwei/Work/PolSAR/PolSAR/utils/armadillo-5.200.2/mex_interface/armaMex_demo.mexa64+00035444
[  9] 0x00007fd66cf43542 /home/weiwei/Work/PolSAR/PolSAR/utils/armadillo-5.200.2/mex_interface/armaMex_demo.mexa64+00013634 mexFunction+00002831
[ 10] 0x00007fd74647272a     /usr/local/MATLAB/R2014a/bin/glnxa64/libmex.so+00120618 mexRunMexFile+00000090
[ 11] 0x00007fd74646ea94     /usr/local/MATLAB/R2014a/bin/glnxa64/libmex.so+00105108
[ 12] 0x00007fd74646ffb4     /usr/local/MATLAB/R2014a/bin/glnxa64/libmex.so+00110516
[ 13] 0x00007fd745869ad9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_dispatcher.so+00670425 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00000697
[ 14] 0x00007fd744b062b4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04461236
[ 15] 0x00007fd744b07bc9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04467657
[ 16] 0x00007fd744b083fc /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04469756
[ 17] 0x00007fd7449826e3 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02873059
[ 18] 0x00007fd74499209e /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02936990
[ 19] 0x00007fd744992183 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02937219
[ 20] 0x00007fd744ac8172 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04206962
[ 21] 0x00007fd7448fd589 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02327945
[ 22] 0x00007fd744900167 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02339175
[ 23] 0x00007fd7448fe26f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02331247
[ 24] 0x00007fd7448feec4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02334404
[ 25] 0x00007fd74495c30b /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02716427
[ 26] 0x00007fd745869c5f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_dispatcher.so+00670815 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00001087
[ 27] 0x00007fd74494020e /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02601486
[ 28] 0x00007fd7448e11b0 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02212272
[ 29] 0x00007fd7448fc25f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02323039
[ 30] 0x00007fd744900167 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02339175
[ 31] 0x00007fd7448fe26f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02331247
[ 32] 0x00007fd7448feec4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02334404
[ 33] 0x00007fd74495c30b /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02716427
[ 34] 0x00007fd745869c5f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_dispatcher.so+00670815 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00001087
[ 35] 0x00007fd74492f135 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02531637
[ 36] 0x00007fd7448f60d9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02298073
[ 37] 0x00007fd7448f2dc7 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02284999
[ 38] 0x00007fd7448f3193 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02285971
[ 39] 0x00007fd74669cafc /usr/local/MATLAB/R2014a/bin/glnxa64/libmwbridge.so+00142076
[ 40] 0x00007fd74669d791 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwbridge.so+00145297 _Z8mnParserv+00000721
[ 41] 0x00007fd74f95392f   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00489775 _ZN11mcrInstance30mnParser_on_interpreter_threadEv+00000031
[ 42] 0x00007fd74f934b6d   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00363373
[ 43] 0x00007fd74f934be9   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00363497
[ 44] 0x00007fd744028d46   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwuix.so+00343366
[ 45] 0x00007fd74400b382   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwuix.so+00222082
[ 46] 0x00007fd7500a950f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02323727
[ 47] 0x00007fd7500a967c /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02324092
[ 48] 0x00007fd7500a557f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02307455
[ 49] 0x00007fd7500aa9b5 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02329013
[ 50] 0x00007fd7500aade7 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02330087
[ 51] 0x00007fd7500ab4c0 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02331840 _Z25svWS_ProcessPendingEventsiib+00000080
[ 52] 0x00007fd74f935098   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00364696
[ 53] 0x00007fd74f9353bf   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00365503
[ 54] 0x00007fd74f93028f   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00344719
[ 55] 0x00007fd74e8de182              /lib/x86_64-linux-gnu/libpthread.so.0+00033154
[ 56] 0x00007fd74e60b47d                    /lib/x86_64-linux-gnu/libc.so.6+01025149 clone+00000109


Abnormal termination:
Segmentation violation

Register State (from fault):
  RAX = 0000000000000001  RBX = 0000000000000000
  RCX = 0000001000000004  RDX = 0000000000248729
  RSP = 00007fd737ff9538  RBP = 0000000000000000
  RSI = 00007fd6b6ddd6b0  RDI = 00007fd737ff9500

   R8 = 0000001000000001   R9 = 0000000000000004
  R10 = 0000000000000003  R11 = 00007fd74e698a30
  R12 = 0000000000000000  R13 = 0000001000000005
  R14 = 00007fd6b6ddd6b0  R15 = 0000000000000000

  RIP = 00007fd68e7a0872  EFL = 0000000000010287

   CS = 0033   FS = 0000   GS = 0000

Stack Trace (from fault):
[  0] 0x00007fd68e7a0872        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+15415410 mkl_blas_avx2_idamax+00000626
[  1] 0x00007fd68e05faae        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07809710 mkl_lapack_dgetf2+00000238
[  2] 0x00007fd68e05f869        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07809129 mkl_lapack_dgetrf_local+00001369
[  3] 0x00007fd68e05f4ae        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07808174 mkl_lapack_dgetrf_local+00000414
[  4] 0x00007fd68e05f4ae        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07808174 mkl_lapack_dgetrf_local+00000414
[  5] 0x00007fd68e05f4ae        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07808174 mkl_lapack_dgetrf_local+00000414
[  6] 0x00007fd68e05f4ae        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+07808174 mkl_lapack_dgetrf_local+00000414
[  7] 0x00007fd68dab6562        /usr/local/MATLAB/R2014a/bin/glnxa64/mkl.so+01873250 mkl_lapack_dgetrf+00003810
[  8] 0x00007fd66cf48a74 /home/weiwei/Work/PolSAR/PolSAR/utils/armadillo-5.200.2/mex_interface/armaMex_demo.mexa64+00035444
[  9] 0x00007fd66cf43542 /home/weiwei/Work/PolSAR/PolSAR/utils/armadillo-5.200.2/mex_interface/armaMex_demo.mexa64+00013634 mexFunction+00002831
[ 10] 0x00007fd74647272a     /usr/local/MATLAB/R2014a/bin/glnxa64/libmex.so+00120618 mexRunMexFile+00000090
[ 11] 0x00007fd74646ea94     /usr/local/MATLAB/R2014a/bin/glnxa64/libmex.so+00105108
[ 12] 0x00007fd74646ffb4     /usr/local/MATLAB/R2014a/bin/glnxa64/libmex.so+00110516
[ 13] 0x00007fd745869ad9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_dispatcher.so+00670425 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00000697
[ 14] 0x00007fd744b062b4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04461236
[ 15] 0x00007fd744b07bc9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04467657
[ 16] 0x00007fd744b083fc /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04469756
[ 17] 0x00007fd7449826e3 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02873059
[ 18] 0x00007fd74499209e /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02936990
[ 19] 0x00007fd744992183 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02937219
[ 20] 0x00007fd744ac8172 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+04206962
[ 21] 0x00007fd7448fd589 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02327945
[ 22] 0x00007fd744900167 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02339175
[ 23] 0x00007fd7448fe26f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02331247
[ 24] 0x00007fd7448feec4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02334404
[ 25] 0x00007fd74495c30b /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02716427
[ 26] 0x00007fd745869c5f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_dispatcher.so+00670815 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00001087
[ 27] 0x00007fd74494020e /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02601486
[ 28] 0x00007fd7448e11b0 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02212272
[ 29] 0x00007fd7448fc25f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02323039
[ 30] 0x00007fd744900167 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02339175
[ 31] 0x00007fd7448fe26f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02331247
[ 32] 0x00007fd7448feec4 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02334404
[ 33] 0x00007fd74495c30b /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02716427
[ 34] 0x00007fd745869c5f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_dispatcher.so+00670815 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+00001087
[ 35] 0x00007fd74492f135 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02531637
[ 36] 0x00007fd7448f60d9 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02298073
[ 37] 0x00007fd7448f2dc7 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02284999
[ 38] 0x00007fd7448f3193 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwm_interpreter.so+02285971
[ 39] 0x00007fd74669cafc /usr/local/MATLAB/R2014a/bin/glnxa64/libmwbridge.so+00142076
[ 40] 0x00007fd74669d791 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwbridge.so+00145297 _Z8mnParserv+00000721
[ 41] 0x00007fd74f95392f   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00489775 _ZN11mcrInstance30mnParser_on_interpreter_threadEv+00000031
[ 42] 0x00007fd74f934b6d   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00363373
[ 43] 0x00007fd74f934be9   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00363497
[ 44] 0x00007fd744028d46   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwuix.so+00343366
[ 45] 0x00007fd74400b382   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwuix.so+00222082
[ 46] 0x00007fd7500a950f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02323727
[ 47] 0x00007fd7500a967c /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02324092
[ 48] 0x00007fd7500a557f /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02307455
[ 49] 0x00007fd7500aa9b5 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02329013
[ 50] 0x00007fd7500aade7 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02330087
[ 51] 0x00007fd7500ab4c0 /usr/local/MATLAB/R2014a/bin/glnxa64/libmwservices.so+02331840 _Z25svWS_ProcessPendingEventsiib+00000080
[ 52] 0x00007fd74f935098   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00364696
[ 53] 0x00007fd74f9353bf   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00365503
[ 54] 0x00007fd74f93028f   /usr/local/MATLAB/R2014a/bin/glnxa64/libmwmcr.so+00344719
[ 55] 0x00007fd74e8de182              /lib/x86_64-linux-gnu/libpthread.so.0+00033154
[ 56] 0x00007fd74e60b47d                    /lib/x86_64-linux-gnu/libc.so.6+01025149 clone+00000109


Abnormal termination:
Segmentation violation

Register State (from fault):
  RAX = 0000000000000002  RBX = 0000000000000000
  RCX = 0000001000000004  RDX = 0000000000251169
  RSP = 00007fd737ff9538  RBP = 0000000000000000
  RSI = 00007fd6b6d984b0  RDI = 00007fd737ff9500

   R8 = 0000001000000001   R9 = 0000000000000004
  R10 = 0000000000000003  R11 = 00007fd74e698a30
  R12 = 0000000000000000  R13 = 0000001000000005
  R14 = 00007fd6b6d984b0  R15 = 0000000000000000

  RIP = 00007fd68e7a0872  EFL = 0000000000010283

   CS = 0033   FS = 0000   GS = 0000

【问题讨论】:

【参考方案1】:

尝试添加在我的代码中使用的犰狳演员,效果很好:

`vec x = conv_to<vec>::from(armaGetPr(prhs[0],true));`

欲了解更多信息,请参阅:http://sigpack.sourceforge.net/build.html

【讨论】:

以上是关于在 Ubuntu 14.04 和 matlab 2014Ra 上使用犰狳在 mex 中出现分段错误的主要内容,如果未能解决你的问题,请参考以下文章

Ubuntu14.04下安装matlab2014a

ubuntu14.04下安装cudnn5.1.3,opencv3.0,编译caffe及matlab和python接口过程记录

[Caffe学习日志] 在Ubuntu14.04上安装MATLAB2014a并编译其接口

如何在不“杀死” Unity 的情况下在 Ubuntu 14.04 中安装 Matlab MCR?

Ubuntu14.04下安装MATLAB后,通过命令行打开其图形界面

ubuntu14.04&matlab2015b 测试caffe的Matlab接口