Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
segmentation error

Subject: segmentation error

From: shopana

Date: 8 Jan, 2008 13:01:02

Message: 1 of 7

hi all..

  im getting the following segmentation error when i try
to call functions using calllib

calllib('Sand_RC','rc_firmwareid_get',libpointer)

Saving minidump to file C:\DOCUME~1\seswaran\LOCALS~1
\Temp\matlab_crash_dump.144.0.dmp

-----------------------------------------------------------
-------------
       Segmentation violation detected at Tue Jan 08
18:08:33 2008
-----------------------------------------------------------
-------------

Configuration:
  MATLAB Version: 7.5.0.342 (R2007b)
  MATLAB License: 361308
  Operating System: Microsoft Windows XP
  Window System: Version 5.1 (Build 2600: Service Pack
2)
  Processor ID: x86 Family 15 Model 11 Stepping 2,
AuthenticAMD
  Virtual Machine: Java 1.6.0 with Sun Microsystems Inc.
Java HotSpot(TM) Client VM mixed mode
  Default Charset: windows-1252

Register State:
  EAX = 00000000 EBX = 00000040
  ECX = 00000000 EDX = 00000093
  ESI = 000000c0 EDI = 00cee0ec
  EBP = 00cee124 ESP = 00cee0ac
  EIP = 12ce3512 FLG = 00010216

Stack Trace:
  [0] libusb0.dll:0x12ce3512(0, 192, 147, 64)
  [1] Sand_RC.dll:0x12c82289(0, 192, 147, 64)
  [2] Sand_RC.dll:0x12c843c3(0, 0, 64, 128)
  [3] Sand_RC.dll:0x12c84b54(0, 0x1241127f,
0x00cee300 "<??", 0x6e724c72)
  [4] libmwcli.dll:void * __cdecl callfcn(void const
*,void const *,int)(0x12c81163, 0x1262d398, 4, 0x12416e5c)
+ 35 bytes
  [5] libmwcli.dll:??
$MakeCall@J@@YAJP6APAXPBX0H@ZABVNativeCall@@PAX@Z
(0x6e728b60, 0x12416e5c, 0x12c81163, 0xdb044b23) + 34 bytes
  [6] libmwcli.dll:public: void __thiscall CCallMI::CallFcn
(class UDMethodSignature *,void * *)(0x12a5d3c0,
0x00cee39c, 0x12416e40, 0x00cee39c) + 610 bytes
  [7] libmwcli.dll:public: virtual void __thiscall
CCallMI::invokeMethod(class UDMethodSignature *,int *,void
* *,int,void * *)(0x12a5d3c0, 0x00cee3c0, 0x00cee39c, 1) +
277 bytes
  [8] libmwcli.dll:void __cdecl CallLibFunction(char
*,char *,int,struct mxArray_tag * * const,int,struct
mxArray_tag const * * const)(0x14d8b4b0 "Sand_RC",
0x12a59520 "rc_firmwareid_get", 0, 0x00cee4c4) + 534 bytes
  [9] libmwcli.dll:_mfCallLib(0, 0x00cee4c4, 3,
0x14d8b4b0 "Sand_RC") + 151 bytes
  [10] m_dispatcher.dll:public: virtual void __thiscall
Mfh_builtin::dispatch_mf(int,struct mxArray_tag *
*,int,struct mxArray_tag * *)(0, 0x00cee4c4, 3,
0x00cee524) + 112 bytes
  [11] m_dispatcher.dll:public: virtual void __thiscall
Mfh_MATLAB_fn::dispatch_fh(int,struct mxArray_tag *
*,int,struct mxArray_tag * *)(0, 0x00cee4c4, 3,
0x00cee524) + 163 bytes
  [12] m_interpreter.dll:__catch$?
inDispatchFromStack@@YAHHPBDHH@Z$0(150,
0x5d03d320 "calllib", 0, 3) + 744 bytes
  [13] m_interpreter.dll:enum opcodes __cdecl
inDispatchCall(char const *,int,int,int,int *,int *)
(0x5d03d320 "calllib", 150, 0, 3) + 156 bytes
  [14] m_interpreter.dll:int __cdecl inInterp(enum
inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag
volatile *,int *)(2, 0, 0, 0) + 2739 bytes
  [15] m_interpreter.dll:int __cdecl protected_inInterp
(enum inDebugCheck,int,int,enum opcodes,struct
inPcodeNest_tag *,int *)(2, 0, 0, 0) + 87 bytes
  [16] m_interpreter.dll:int __cdecl inInterPcodeSJ(enum
inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag
*,int *)(2, 0, 0, 0) + 274 bytes
  [17] m_interpreter.dll:_inInterPcode(2, 0x9ba70b24, 0,
0x127c8820 "calllib('Sand_RC','rc_firmwa..") + 162 bytes
  [18] m_interpreter.dll:enum inExecutionStatus __cdecl
in_local_call_eval_function(int *,struct _pcodeheader
*,int *,struct mxArray_tag * * const,enum
inDebugCheck,bool)(0x00cef2bc, 0x00cef32c, 0x00cef358, 2)
+ 152 bytes
  [19] m_interpreter.dll:enum inExecutionStatus __cdecl
inEvalStringWithIsVarFcn(struct _memory_context *,char
const *,enum EvalType,int,struct mxArray_tag * *
const,enum inDebugCheck,struct _pcodeheader *,int *,bool
(__cdecl*)(void *,char const *),void *,bool)(0x7ac2177c,
0x127c8820 "calllib('Sand_RC','rc_firmwa..", 0, 0) + 2454
bytes
  [20] m_interpreter.dll:enum inExecutionStatus __cdecl
inEvalCmdWithLocalReturnandtype(char const *,int *,enum
inDebugCheck,bool)(0x127c8820 "calllib
('Sand_RC','rc_firmwa..", 0, 2, 0) + 107 bytes
  [21] m_interpreter.dll:_inEvalCmdNoEnd
(0x127c8820 "calllib('Sand_RC','rc_firmwa..", 0,
0x9b5cd7a6, 0x7ab9e7f0) + 20 bytes
  [22] bridge.dll:enum inExecutionStatus __cdecl
ThrowSignal(char const *)(0x127c8820 "calllib
('Sand_RC','rc_firmwa..", 0x9b5cd0ea, 0x014c4010,
0x014c3fb0) + 77 bytes
  [23] bridge.dll:__catch$_mnParser$0(0x9b597135,
0x014c3fb0, 0x014c3fb0, 0) + 292 bytes
  [24] mcr.dll:public: void __thiscall
mcrInstance::mnParser(void)(0x9b597838, 0x004043f0,
336710, 0) + 62 bytes
  [25] MATLAB.exe:0x00401414(4194304, 0, 336710, 10)
  [26] MATLAB.exe:0x00401733(0, 0, 0x7ffdf000, 0x8054a6ed)
  [27] kernel32.dll:0x7c816fd7(0x00401910, 0, 0x78746341,
32)

Please follow these steps to report this problem to The
MathWorks so we
have the best chance of correcting it:

The next time MATLAB is launched under typical usage, a
dialog box will
open to help you send the error log to The MathWorks.
Alternatively, you
can send an e-mail to segv@mathworks.com with the
following file attached:
    C:\DOCUME~1\sesw\LOCALS~1\Temp\matlab_crash_dump.144

    can anyone help me?thanks

Subject: segmentation error

From: Malcolm Lidierth

Date: 8 Jan, 2008 19:18:01

Message: 2 of 7

You seem to be passing an empty pointer to your dll hence
the memory violation.

It is generally simplest to pass MATLAB variables in callib.
If these are non-scalar they will need to be pre-allocated
to prevent memory overruns (the dll receives a pointer and
has no idea of matlab matrix size)

e.g.

string=char(zeros(1,80));
string=calllib('dll', 'procname', fh, n, string, 79);

Watch out for the terminating null when using strings.

Subject: segmentation error

From: shopana

Date: 9 Jan, 2008 04:31:02

Message: 3 of 7

"Malcolm Lidierth" <ku.ca.lck@htreidil.mloclam> wrote in
message <fm0i99$60m$1@fred.mathworks.com>...
> You seem to be passing an empty pointer to your dll
hence
> the memory violation.
>
> It is generally simplest to pass MATLAB variables in
callib.
> If these are non-scalar they will need to be pre-
allocated
> to prevent memory overruns (the dll receives a pointer
and
> has no idea of matlab matrix size)
>
> e.g.
>
> string=char(zeros(1,80));
> string=calllib('dll', 'procname', fh, n, string, 79);
>
> Watch out for the terminating null when using strings.

thanks for your help,but my return value i.e, libpointer
is scalar ,also that value is coming from the another
calllib function.Here is my code.

A1=calllib('Sand_RC','rc_open',6,70)
A1 =
 
libpointer

calllib('Sand_RC','rc_deviceid_get,A1)


i dont know want i did wrong here.can you help me?
 

Subject: segmentation error

From: shopana

Date: 9 Jan, 2008 08:13:03

Message: 4 of 7

"shopana " <shopana.e@hcl.in> wrote in message <fm1im6
$8ck$1@fred.mathworks.com>...
> "Malcolm Lidierth" <ku.ca.lck@htreidil.mloclam> wrote in
> message <fm0i99$60m$1@fred.mathworks.com>...
> > You seem to be passing an empty pointer to your dll
> hence
> > the memory violation.
> >
> > It is generally simplest to pass MATLAB variables in
> callib.
> > If these are non-scalar they will need to be pre-
> allocated
> > to prevent memory overruns (the dll receives a pointer
> and
> > has no idea of matlab matrix size)
> >
> > e.g.
> >
> > string=char(zeros(1,80));
> > string=calllib('dll', 'procname', fh, n, string, 79);
> >
> > Watch out for the terminating null when using strings.
>
> thanks for your help,but my return value i.e, libpointer
> is scalar ,also that value is coming from the another
> calllib function.Here is my code.
>
> A1=calllib('Sand_RC','rc_open',6,70)
> A1 =
>
> libpointer
>
> calllib('Sand_RC','rc_deviceid_get,A1)
>
>
> i dont know want i did wrong here.can you help me?
>
>

Subject: segmentation error

From: Malcolm Lidierth

Date: 9 Jan, 2008 13:16:02

Message: 5 of 7

The pointer A1 presumbaly then points to memory outside the
MATLAB workspace as it is allocated by the first calllib.

What do you see with get(A1) and libfunctions for these dll
routines?

Subject: segmentation error

From: shopana

Date: 10 Jan, 2008 06:09:01

Message: 6 of 7

"Malcolm Lidierth" <ku.ca.lck@htreidil.mloclam> wrote in
message <fm2hei$3i8$1@fred.mathworks.com>...
> The pointer A1 presumbaly then points to memory outside
the
> MATLAB workspace as it is allocated by the first calllib.
>
> What do you see with get(A1) and libfunctions for these
dll
> routines?
>
>


get(a1),returns the error message:
??? Error using ==> get
Invalid handle object.

libfunction list the available functions in DLL. how to
rectify this(The pointer A1 presumbaly then points to
memory outside the MATLAB workspace as it is allocated by
the first calllib).thank you

Subject: segmentation error

From: Malcolm Lidierth

Date: 10 Jan, 2008 10:50:19

Message: 7 of 7

So it looks as though A1 is not a libpointer.

>> A1=3

A1 =

     3

>> get(A1)
??? Error using ==> get
Invalid handle object.


>> A1=libpointer('double',1)
 
A1 =
 
libpointer
>> get(A1)
       Value: 1
    DataType: 'double'

>> class(A1)

ans =

lib.pointer

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us