f



MATLAB crashes by calling this mex file

I am using the following mex syntax/definition. I build the mex in MATLAB but when calling the generated mex, MATLAB crashes. I have tried mex -g option but still when debugging, MATLAB crashes. When I debug the ".cpp" file in Visual Studio, it runs perfectly and generates the correct results but running the generated "mex" seems impossible. How can I find the source of memory leakage?

"
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )  { double *expected_output, *apriori_uncoded_llrs, *encoded_input, sigma2, *extrinsic_uncoded_llrs;  int length,TRANSITION_COUNT;  size_t mrows1,ncols1,mrows2,ncols2;  mrows1=mxGetM(prhs[0]); ncols1=mxGetN(prhs[0]);mrows2=mxGetM(prhs[1]); ncols2=mxGetN(prhs[1]); TRANSITION_COUNT = (int) ncols1; length = (int) ncols2;

/* Create matrix for the return argument. */
plhs[0] = mxCreateDoubleMatrix((mwSize)mrows1, (mwSize)ncols1, mxREAL);  
/* Assign pointers to each input and output. */
expected_output = mxGetPr(prhs[0]);
apriori_uncoded_llrs = mxGetPr(prhs[1]);
encoded_input = mxGetPr(prhs[2]);
sigma2 = *mxGetPr(prhs[3]);
extrinsic_uncoded_llrs = mxGetPr(plhs[0]);

/* Call the bcjr_decoder subroutine. */
bcjrequalizer(expected_output, apriori_uncoded_llrs, encoded_input, sigma2, length, TRANSITION_COUNT, extrinsic_uncoded_llrs);
}
"

Thanks,
Elnaz
0
Elnaz
8/24/2014 4:59:08 PM
comp.soft-sys.matlab 211266 articles. 24 followers. lunamoonmoon (257) is leader. Post Follow

1 Replies
418 Views

Similar Articles

[PageSpeed] 34

On 08/24/2014 11:59 AM, Elnaz wrote:
> I am using the following mex syntax/definition. I build the mex in
> MATLAB but when calling the generated mex, MATLAB crashes. I have tried
> mex -g option but still when debugging, MATLAB crashes. When I debug the
> ".cpp" file in Visual Studio, it runs perfectly and generates the
> correct results but running the generated "mex" seems impossible. How
> can I find the source of memory leakage?
....

It's unlikely a memory leak but a bad pointer...almost always the 
problem with mex files that crash spectacularly.

I "know nuthink!" of cpp so won't even attempt to read the code but my 
starting point for mex files is almost always one of the working 
examples that uses the type of arguments I'm intending to pass.

When I have its interface working, _then_ I begin modifying it to my 
purposes.  I've found this almost always gets me by the problems in the 
interface that I tend to forget owing to being so long between times I 
write mex-files any more.  It was one thing when was doing it regularly, 
but those days are long in the past and similarly if one hasn't a lot of 
previous experience it's easy to get wrong...

--

0
dpb
8/24/2014 7:17:28 PM
Reply:

Similar Artilces:

Matlab crashes while calling Mex file
Hi, My problem is as follows: I created a mex file called getCg(), in order to use some functions of the c-files I have in my matlab model. Problem is, after calling the mex file 'getCg()' several times matlab crashes. That is, when I write >>for i=1:28, a(i) = getCgOnGas(50*i); end command several times matlab crashes immediately. Do you have any idea what could be the reason? Here is the mex file I have: #include<mex.h> #include"gas.h" #include"gasdb.h" #include"global.h" #include"heat.h" #include"hss.h" #include"...

how to call matlab file to another matlab file
Hey friends, i am working on simulation of power system using matlab. for that i have written codes for generation side and line side separately. Now i want to use the result of generation file to line file....so how can i use the result of one file to another.... eg i have gen.m file from that i can get hourly gen data....now i want to compare that data to line.....and line modelling is done in separate file line.m so i want to call result of gen.m file to line.m file..... waiting for ur valuable suggestion thanks ...

mex - matlab calls fortran which calls matlab which calls fortran
Dear All, I'm trying to link matlab and fortran with mex files and engine matlab, in linux OS. My general purpose is the following: 1) a matlab script A calls a mex function B based upon fortran source code 2) mex function B calls another function in matlab C within matlab engine 3) matlab routine C calls another mex file in fortran D While i'm able to do steps 2) and 3), I can't do step 1). Before to show the code, please reply to this simple question: Is it possible to build the overall process 1-3? On 8 Okt, 16:37, "Michele Catalano" <cata...@yahoo.it> wr...

MATLAB crashing with MEX file in function working well outside of MATLAB
Hi Everyone, I have an high level problem (I believe) that I will try to explain; My development platform is: 64bit Ubuntu 12.04 LTS and MATLAB 2013b with GCC/G++-4.7 library I am trying to create a MATLAB interface by coding a MexFunction using gigantic C++ library previously developed. For the tests I previously build and MexFunction only using and parsing XML files as inputs where paths are hardly defined within the function (for simplification and debugging), and I am not passing any input and output with *plhs and *prhs yet. My code includes MexFunction can be compiled with...

C++ Mex file crashes matlab on 64bit linux, but not 32 bit windows, but program runs fine outside Matlab
Hello, I have written a mex gateway function to a C++ class. If I compile this mex function on 32Bit windows using R2008a I have no problems. If I compile and run on Matlab R2011a running 64bit Scientific Linux (a version of Red Hat Enterprize Linux) matlab exits with a segfault when the mexfunction is called, although it appears to run about halfway through the program. The C++ class can be compiled and run (with a main function) outside of Matlab on both platforms with no errors. I am using Microsoft Visual C++ Express Edition on the windows machine, and gcc 4.4.5 on the Linux machine. ...

How to call or pass MATLAB file pointer in C Mex file?
Hello all, 1. I am trying to read large binary data files (~1 GB size), process the information and dump the outputs (which are also of incredibly big size) to MATLAB workspace. I wrote a mex file to do the same (so that I have faster program execution speeds). 2. The C mex file that I wrote works very well and can dump all the variables to MATLAB workspace for smaller size files. However for larger binary files, the MATLAB gives OUT OF MEMORY error as the size of the variable space is simply too big. 3. Often I am not interested in all portions of the file and don't need all the variab...

Matlab crashes because of Mex-file
I have two machines, hosted in 2 different departments. They both run on Ubuntu 9 and use Matlab 2009a. The different is: one is a 32bit machine while the other is 64bit. A Professor sent me a Mex file and a Matlab file calling this Mex file. I can compile the Mex file on both machines. However, when I call the Matlab file on the 64bit machine, Matlab crashes saying "Segmentation Violation detected" and "This error was detected while a MEX-file was running". There's no problem that Matlab file on the other machine. Because the 64bit machine is my main workstation, I r...

MATLAB crashes with mex files
Is there any method by which we can come to know the errors in our mex files. Currently, MATLAB just crahes as soon as I try to compile the mex file. ...

Mex file crashes Matlab
Hello all, I created successfully a mex file. It is linked to an external dll and it worked fine (it returns correctly to matlab a vector). Recently I added an new function inside my c++ file which does not affect the result of the c++ function but is just used to improve some data manipulation. By the way, this function works quite well in a simple c++ file and I have already used many times in other c++ files (no-mex files). After added this function my matlab crashes and returns me this error: MATLAB crash file:C:\DOCUME~1\MILCEMEA~1.VAA\LOCALS~1\Temp\matlab_crash_dump.2996 ------...

mex file, matlab crashes
I have a mex file, i deallocate memory for every thing i use, apart from a waveform which receive.I allocate space for it through mxCalloc and doesnot set if free. the matlab call is [a,b]=my_func(c,d) the mex file compiles smoothly and the first time i call the function in matlab, it works smoothly, but when i call the function again , the workspace goes blank, though if i type 'a' in command window, i can see the contents of a, and i can plot the contents of a too, now if i plot again, the matlab simply crashes (segment violation), it says to save ur work and restart matlab, ...

Call C code from Matlab -> Matlab crash
Hello, I have a problem calling C code from Matlab. The mex file compilation is ok. When I run the program Matlab (7.3) crashes. Below is the mexFunction code. Any idea is welcome. (I think the main part of the code (middle part) is not useful for the crash problem, but I put it anyway). //########################################################### #include "math.h" #include "mex.h" void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { // Standard variables int p,r,h,i,j,f,w; // Indices for loop int MAX_NBM = 1000; int MAX_DIM = 10; in...

Call Matlab m-file from Matlab Scrip Node
My problem with matlab script node is related to calling function in matlab.&nbsp; I created an m-file function that takes an imput temperature (from DAQ) and defines a material property.&nbsp; My matlab script node doesn't seem to recognize my function.&nbsp; I have placed the function in the folder the vi is currently located, but it doesn't read it.&nbsp; How do I get matlab script node to read the functions I create in matlab? Add the directory to matlab path, or call the .m file with it full name ( D:\..... \myfile.m) Let me clarify, &nbsp; I have pasted my m...

Call C code from Matlab -> Matlab crash #2
Hello, I have a problem calling C code from Matlab. The mex file compilation is ok. When I run the program Matlab (7.3) crashes. Below is the mexFunction code. Any idea is welcome. (I think the main part of the code (middle part) is not useful for the crash problem, but I put it anyway). //########################################################### #include "math.h" #include "mex.h" void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { // Standard variables int p,r,h,i,j,f,w; // Indices for loop int MAX_NBM = 1000; int MAX_DIM = 10; in...

mex/matlab crashing after opengl calls
This is kind of a strange problem I have uncovered. First I have compiled a mex interface to a C++ library I wrote. All interactions with the mex'ed library works fine until I create a figure window using OpenGL as the renderer. Any interaction with my library after creating the window brings everything crashing down. Here are some examples of reproducing this behavior: Steps to reproduce crash: yamokosk@selvik:~/code/sceneml$ matlab -nojvm -nosplash < M A T L A B > Copyright 1984-2007 The MathWorks, Inc. Version 7.4.0.3...

Web resources about - MATLAB crashes by calling this mex file - comp.soft-sys.matlab

Lightning Crashes - Wikipedia, the free encyclopedia
" Lightning Crashes " is a song by the rock band Live , from their 1994 album, Throwing Copper . The track wasn't released as a single in the ...

When New York Times website crashes, newspaper turns to Facebook Notes
When The New York Times’ website suffered some downtime Wednesday because of technical issues, the newspaper turned to Facebook Notes to post ...


Adorable Baby Crashes Daddy's Concert - YouTube
17 month old baby, Ethan ran out onstage when his dad, country singer Coffey, was performing at NYE event, started dancing, and stole the show. ...

Syria army plane crashes while bombing rebel-held town
A Syrian military aircraft crashed while on a bombing run over the rebel-held north-western town of Ariha on Monday, leaving at least 12 people ...

Nice Save of the Day: Guy Catches Drone Before It Crashes Into Pond
This man is a hero to drones across the globe. He took his new DJI Phantom 2 out for a spin and was having a great time… until the batteries ...

Man crashes car doing burnouts allegedly twice over limit at Port Pirie - AdelaideNow Search Search
A MAN was arrested after allegedly doing burnouts while almost two times over the limit and crashing into a fence at Port Pirie.

Two die in separate south-east Qld crashes
Two people have been killed in separate single-vehicle crashes in southeast Queensland. Police say a 62-year-old woman died after her car rolled ...

Greenwich, Conn. City Bus Crashes In Snowstorm, 1 Injured « CBS New York
Slick roads as snow fell in Greenwich, Connecticut on Saturday led a bus to slide down a hill and hit a utility pole.

Nine killed in icy crashes throughout the South - Videos - CBS News
The monster storm moving east first slammed parts of the South with snow and ice, causing major problems on the roads, stranding hundreds and ...

Resources last updated: 1/26/2016 2:15:02 PM