Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8826413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:07:48+00:00 2026-06-14T07:07:48+00:00

i followed the solution given here: Passing pointer argument in MATLAB to a C-DLL

  • 0

i followed the solution given here:
Passing pointer argument in MATLAB to a C-DLL function foo(char**)

i add a string received via tcp socket, this is the reduced example

c-dll:

void test(char **u1, char **y1)
{
   std::string recvString("Test Output"); //this string change
   *y1 = (char*) mxRealloc(*y1, recvString.size()+1); //get memory
   *y1 = strdup(recvString.c_str()); //copy
}

matlab:

loadlibrary('rriMonitor.dll', 'rriMonitor.h');

vpu = libpointer('stringPtrPtr',{'test input'});
vpv = libpointer('stringPtrPtr',{''});

calllib('rriMonitor','test',vpu,vpv);
vpv.value{1}    %gives correct string 'Test Output'

%clear vpv; % CRASH also

unloadlibrary 'rriMonitor'

clear vpu; % everything fine
clear vpv; % CRASH

this is working so far. my problem is that a final:

clear vpv  (alias pstr in the example)

crashes matlab ((R2011a) 64-bit)

how to clear the lib.pointer ?

(i tried change java vm, but same behavior)

MATLAB Version  : 7.12.0.635 (R2011a)
Operating System: Microsoft Windows 7
Processor ID    : x86 Family 6 Model 14 Stepping 5, GenuineIntel
Virtual Machine : Java 1.7.0_09-b05 with Oracle Corporation Java HotSpot(TM) 64-Bit    Server VM mixed mode
Window System   : Version 6.1 (Build 7601: Service Pack 1)

Fault Count: 1




Abnormal termination:

Segmentation violation


Register State (from fault):

RAX = 00000000015ccf68  RBX = 000000000e6faab0

RCX = 0000000001e90000  RDX = 0000000000000000

RSP = 00000000015ccef0  RBP = 0000000000000000
RSI = 0000000001e90000  RDI = 000000000e6faac0

R8 = 000000000e6faac0   R9 = 00000000040fa250
R10 = 0000000029c25fa0  R11 = 00000000015cd090
R12 = 000000000422e750  R13 = 0000000000000000
R14 = 0000000000000001  R15 = 000000006156fd40

RIP = 000000007709324e  EFL = 00010246

CS = 0033   FS = 0053   GS = 002b


Stack Trace (from fault):
[  0] 0x000000007709324e                      C:/Windows/SYSTEM32/ntdll.dll+00340558 ( RtlFreeHeap+000078 )
[  1] 0x000000007698300a                   C:/Windows/system32/kernel32.dll+00143370 ( HeapFree+000010 )
[  2] 0x000000006b89cabc C:/Windows/WinSxS/amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_08e61857a83bc251/MSVCR90.dll+00314044 ( free+000028 )
[  3] 0x000007fef131f9d9 C:/Program Files/MATLAB/R2011a/bin/win64/libmwcli.dll+00063961 ( RefDataType::AssignPointer+002153 )
[  4] 0x000007fef131cb2d C:/Program Files/MATLAB/R2011a/bin/win64/libmwcli.dll+00052013 ( callstdfcn+005693 )
[  5] 0x000007fef131c7a4 C:/Program Files/MATLAB/R2011a/bin/win64/libmwcli.dll+00051108 ( callstdfcn+004788 )
[  6] 0x000000005f0a0d83   C:/Program Files/MATLAB/R2011a/bin/win64/udd.dll+00200067 ( UDInterface::destroyInternals+000067 )
[  7] 0x000000005f0a0f06   C:/Program Files/MATLAB/R2011a/bin/win64/udd.dll+00200454 ( UDInterface::destroyUnconditional+000230 )
[  8] 0x000000005f0a1034   C:/Program Files/MATLAB/R2011a/bin/win64/udd.dll+00200756 ( UDInterface::copyE+000052 )
[  9] 0x000000005e1f0750 C:/Program Files/MATLAB/R2011a/bin/win64/udd_mi.dll+00264016 ( judiSetDynamicPropertyValue+008368 )
[ 10] 0x0000000075a28723 C:/Program Files/MATLAB/R2011a/bin/win64/libmx.dll+00034595 ( mxSetObjectCreateDestroyFn+000275 )
[ 11] 0x0000000075a288aa C:/Program Files/MATLAB/R2011a/bin/win64/libmx.dll+00034986 ( mxSetObjectCreateDestroyFn+000666 )
[ 12] 0x0000000075a7e8e5 C:/Program Files/MATLAB/R2011a/bin/win64/libmx.dll+00387301 ( mxClearArrayContents+000021 )
[ 13] 0x0000000051672928 C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+00731432 ( inDestroyWS+465608 )
[ 14] 0x0000000051666932 C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+00682290 ( inDestroyWS+416466 )
[ 15] 0x00000000516754ee C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+00742638 ( inDestroyWS+476814 )
[ 16] 0x0000000051675930 C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+00743728 ( inDestroyWS+477904 )
[ 17] 0x00000000615201a9 C:/Program Files/MATLAB/R2011a/bin/win64/m_dispatcher.dll+00065961 ( mdLogging::log_function_entry+000201 )
[ 18] 0x0000000061520156 C:/Program Files/MATLAB/R2011a/bin/win64/m_dispatcher.dll+00065878 ( mdLogging::log_function_entry+000118 )
[ 19] 0x000000006151fb98 C:/Program Files/MATLAB/R2011a/bin/win64/m_dispatcher.dll+00064408 ( Mfunction_handle::dispatch+000456 )
[ 20] 0x000000005164182b C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+00530475 ( inDestroyWS+264651 )
[ 21] 0x000000005163e082 C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+00516226 ( inDestroyWS+250402 )
[ 22] 0x0000000051654c73 C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+00609395 ( inDestroyWS+343571 )
[ 23] 0x0000000051654dc0 C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+00609728 ( inDestroyWS+343904 )
[ 24] 0x000000005164624b C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+00549451 ( inDestroyWS+283627 )
[ 25] 0x00000000516442ac C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+00541356 ( inDestroyWS+275532 )
[ 26] 0x0000000051651009 C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+00593929 ( inDestroyWS+328105 )
[ 27] 0x000000006151f859 C:/Program Files/MATLAB/R2011a/bin/win64/m_dispatcher.dll+00063577 ( Mfh_file::dispatch_fh+000473 )
[ 28] 0x000000006151fccf C:/Program Files/MATLAB/R2011a/bin/win64/m_dispatcher.dll+00064719 ( Mfunction_handle::dispatch+000767 )
[ 29] 0x00000000516c6de8 C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+01076712 ( inSetPredictor+001000 )
[ 30] 0x00000000516d3415 C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+01127445 ( inInitInterestRegistry+004309 )
[ 31] 0x00000000516d5175 C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+01134965 ( inIsCodeBlockComplete+007445 )
[ 32] 0x00000000516d5148 C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+01134920 ( inIsCodeBlockComplete+007400 )
[ 33] 0x00000000516d510e C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+01134862 ( inIsCodeBlockComplete+007342 )
[ 34] 0x0000000051698113 C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+00885011 ( inGetSeqVarPtrsFromCurrentWS+007315 )
[ 35] 0x00000000516c98e0 C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+01087712 ( inEvalCmdWithLocalReturn+000304 )
[ 36] 0x00000000516c983c C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+01087548 ( inEvalCmdWithLocalReturn+000140 )
[ 37] 0x00000000516c97f1 C:/Program Files/MATLAB/R2011a/bin/win64/m_interpreter.dll+01087473 ( inEvalCmdWithLocalReturn+000065 )
[ 38] 0x0000000079fb833a C:/Program Files/MATLAB/R2011a/bin/win64/libmwbridge.dll+00033594 ( mnDebugPrompt+000106 )
[ 39] 0x0000000079fbd0d2 C:/Program Files/MATLAB/R2011a/bin/win64/libmwbridge.dll+00053458 ( mnParser+000418 )
[ 40] 0x00000000749ab604   C:/Program Files/MATLAB/R2011a/bin/win64/mcr.dll+00243204 ( mcrInstance::mnParser_on_interpreter_thread+000036 )
[ 41] 0x000000007498ed24   C:/Program Files/MATLAB/R2011a/bin/win64/mcr.dll+00126244 ( DepfunRules::postWarning+045636 )
[ 42] 0x000000007498edb1   C:/Program Files/MATLAB/R2011a/bin/win64/mcr.dll+00126385 ( DepfunRules::postWarning+045777 )
[ 43] 0x0000000001b79676   C:/Program Files/MATLAB/R2011a/bin/win64/uiw.dll+00366198 ( UIW_IsUserMessage+000086 )
[ 44] 0x0000000001b79d44   C:/Program Files/MATLAB/R2011a/bin/win64/uiw.dll+00367940 ( ws_ProcessPendingEventsWaitForWindows+000356 )
[ 45] 0x0000000076f687fe                     C:/Windows/system32/USER32.dll+00165886 ( GetMenuBarInfo+000638 )
[ 46] 0x0000000076f4f5fb                     C:/Windows/system32/USER32.dll+00062971 ( SystemParametersInfoW+000235 )
[ 47] 0x0000000076f54895                     C:/Windows/system32/USER32.dll+00084117 ( IsProcessDPIAware+000465 )
[ 48] 0x0000000077091225                      C:/Windows/SYSTEM32/ntdll.dll+00332325 ( KiUserCallbackDispatcher+000031 )
[ 49] 0x0000000076f59e6a                     C:/Windows/system32/USER32.dll+00106090 ( SfmDxSetSwapChainStats+000026 )
[ 50] 0x0000000076f5615e                     C:/Windows/system32/USER32.dll+00090462 ( GetMessageA+000078 )
[ 51] 0x0000000001b53f07   C:/Program Files/MATLAB/R2011a/bin/win64/uiw.dll+00212743 ( UIW_SetCurrentDialog+000855 )
[ 52] 0x0000000001b7b117   C:/Program Files/MATLAB/R2011a/bin/win64/uiw.dll+00373015 ( ws_FreeSystemFont+000519 )
[ 53] 0x000000005e36b7b3 C:/Program Files/MATLAB/R2011a/bin/win64/libuij.dll+00178099 ( sysq::ws_ppeHook::~ws_ppeHook+009539 )
[ 54] 0x000000005e36cf3c C:/Program Files/MATLAB/R2011a/bin/win64/libuij.dll+00184124 ( svWS_CommitDatabaseUpdates+002796 )
[ 55] 0x000000005e36d97a C:/Program Files/MATLAB/R2011a/bin/win64/libuij.dll+00186746 ( svWS_CommitDatabaseUpdates+005418 )
[ 56] 0x000000005e36dbbd C:/Program Files/MATLAB/R2011a/bin/win64/libuij.dll+00187325 ( svWS_CommitDatabaseUpdates+005997 )
[ 57] 0x000000005e36ddb8 C:/Program Files/MATLAB/R2011a/bin/win64/libuij.dll+00187832 ( svWS_CommitDatabaseUpdates+006504 )
[ 58] 0x000000005e36df10 C:/Program Files/MATLAB/R2011a/bin/win64/libuij.dll+00188176 ( svWS_CommitDatabaseUpdates+006848 )
[ 59] 0x000000007498e28f   C:/Program Files/MATLAB/R2011a/bin/win64/mcr.dll+00123535 ( DepfunRules::postWarning+042927 )
[ 60] 0x000000007498f051   C:/Program Files/MATLAB/R2011a/bin/win64/mcr.dll+00127057 ( DepfunRules::postWarning+046449 )
[ 61] 0x000000007498f37e   C:/Program Files/MATLAB/R2011a/bin/win64/mcr.dll+00127870 ( DepfunRules::postWarning+047262 )
[ 62] 0x000000013f527304 C:/Program Files/MATLAB/R2011a/bin/win64/MATLAB.exe+00029444 ( ???+000000 )
[ 63] 0x000000013f5273d9 C:/Program Files/MATLAB/R2011a/bin/win64/MATLAB.exe+00029657 ( ???+000000 )
[ 64] 0x000000013f5278cb C:/Program Files/MATLAB/R2011a/bin/win64/MATLAB.exe+00030923 ( ???+000000 )
[ 65] 0x000000007697652d                   C:/Windows/system32/kernel32.dll+00091437 ( BaseThreadInitThunk+000013 )
[ 66] 0x000000007706c521                      C:/Windows/SYSTEM32/ntdll.dll+00181537 ( RtlUserThreadStart+000033 )
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:07:49+00:00Added an answer on June 14, 2026 at 7:07 am

    SOLVED

    dynamicaly allocated memory has to be released in c first!

    change c-dll function

    void test(char **u1, char **y1)
    {
       std::string recvString("Test Output");
       *y1 = strdup(recvString.c_str()); //allocate and copy 
    }
    

    add c-dll function

    void clear(char** y1)
    {
       free(*y1)
       *y1 = NULL;
    }
    

    add matlab

    loadlibrary('rriMonitor.dll', 'rriMonitor.h');
    
    vpu = libpointer('stringPtrPtr',{'test input'});
    vpv = libpointer('stringPtrPtr',{''});
    
    calllib('rriMonitor','test',vpu,vpv);
    vpv.value{1}    %gives correct string 'Test Output'
    
    calllib('rriMonitor','clear',vpv);
    vpv.value       %null pointer {[]}
    clear all       %works
    
    unloadlibrary 'rriMonitor'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Noob here again. I've followed the example given by Google Dev (and read a
I followed the instructions given in the link: http://blog.avirtualhome.com/how-to-compile-a-new-ubuntu-11-04-natty-kernel/ for building a custom kernel
I followed this post http://neurochannels.blogspot.com/2010/05/how-to-run-r-code-in-matlab.html , to install R(D)Com server in order to call
I followed the example given in ember application stucture guide http://emberjs.com/guides/outlets/ in order to
I have a string in the following format: \main\stream\foo.h\3 it may have more or
Given is a form that is followed by a confirmation page where you have
I try to add a recaptcha field to my registration form and followed Marcos
I am trying to implement the solution given in Handling Concurrency with the Entity
Followed this question about delayed_job and monit Its working on my development machine. But
I followed the instructions on source.android.com to build the Android framework, but when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.