|
From: Rahul <rah...@ya...> - 2006-07-27 12:20:28
|
Hi,
I'm trying to debug a C file which is actually a
MEX (C) file interfacing with Matlab. I compile
the file in question with the -g option like:
$ mex -g file.c
Then I start up matlab using the command:
$ matlab -arch=glnx86 -nosplash -nojvm
-D"valgrind --error-limit=no
--tool=memcheck -v --leak-check=yes"
Once I get into matlab, I run my matlab
program (which calls the C file). Just before
a segmentation fault occurs, I get the
following messages:
Note: I've removed the PID to fit the 80
character limit
Invalid read of size 4
at 0x1B984585: (within /usr/local/matlab71/bin/glnx86/libut.so)
by 0x1B984CEA: (within /usr/local/matlab71/bin/glnx86/libut.so)
by 0x1B987B3C: utCalloc (in /usr/local/matlab71/bin/glnx86/libut.so)
by 0x1BA11025: (within /usr/local/matlab71/bin/glnx86/libmx.so)
Address 0x61CD5411 is not stack'd, malloc'd or (recently) free'd
Stack Trace:
Invalid read of size 4
at 0x1B984585: (within /usr/local/matlab71/bin/glnx86/libut.so)
Address 0x61CD5411 is not stack'd, malloc'd or (recently) free'd
Syscall param write(buf) contains uninitialised or unaddressable byte(s)
at 0xCD4BBB: (within /lib/tls/libc-2.3.4.so)
Address 0x1FDCA3DE is on thread 1's stack
warning: Valgrind's siglongjmp is incomplete
(it ignores cleanup handlers)
your program may misbehave as a result
Warning: client switching stacks? %esp: 0x1EB13C7C --> 0x52BF8600
Now, this error occurs when some Matlab code is running,
not the interfaced C code (but the C code is causing the
problem because, if I replace the C code with equivalent
Matlab code instead, there are no problems). More
specifically, I know that the C problem is causing some
problems which is affecting the Matlab heap or stack,
which is leading to the segmentation fault in question.
>From the documentation I understand that the error
indicates that an illegal memory location is being
accessed. But the above error message doesn't seem
to indicate which line in my code possibly caused the
problem. Is there any way I can get this or
some other information that will help me diagnose the
problem more specifically? Or is this already present
above and am I missing it?
Any help would be greatly appreciated!
Thanks in advance,
Rahul.
|