Hi David,

I think we can all agree that the community starting to run at the
mention of Matlab is not a good thing - I think there might be
frustration behind this flight instinct, so let's try to make this a
success story.

I concur with the pretty detailed reply from mathworks; the reason is
likely to be the binary/abi mismatch between the boost GNU Radio/your
native runtime linker uses and the one that the Matlab library needs.

Now, you should be able to specify the boost that cmake uses when
configuring the build process:
cmake -DBOOST_INCLUDEDIR=<matlab-shipped boost includes>
-DBOOST_LIBRARY_DIR=<matlab-shipped library dir> ..
Also make sure to specify export LD_LIBRARY_DIR containing the same
matlab library dir; otherwise, at runtime your system's boost will get
linked in, and that will still result in segfaults.

Maybe there is also the option to statically link the Matlab library
before loading it from GNU Radio, instead of doing it the other way
around (which is option 2). To me, that sounds more logically sound,
since it's Matlab that introduces library dependencies that are
incompatible with your system libraries, because otherwise you might run
into the same problem for other libraries that both Mathworks code and
GNU Radio use and Mathworks ships their own version with. However, I
don't know if that would even be possible, as I don't have Matlab around
to test it.

All in all, I also like option 3 from Mathwork's reply, though I don't
think the .mat method would work well for streaming like GNU Radio does;
you should be able to just open a file (fopen) and read from it (fread)
in a loop, so that you can get what a file source in GNU Radio writes to
a FIFO; basically, as Matlab pseudocode:

infile = fopen("/tmp/fifo_in");
outfile = fopen("/tmp/fifo_out", "w");
while 1
    datain = fread(infile, 1000, "float32");
    dataout = do_some_processing(datain);
    fwrite(outfile, dataout, "float32");
end

you'd have to

mkfifo /tmp/fifo_in /tmp/fifo_out

first and then use file sink/source to write/read to/from these.

Of course, a socket- or IPC-based solution might be cleaner, but I don't
know much popular matlab tools that make it easy to write "real-world
compatible" Matlab code (I think that lack of knowledge of high-quality
well-known libraries might be what leads people to run away as soon as
you mention Matlab).

Best regards,
Marcus


Am 17. August 2015 12:27:25 MESZ, schrieb David Halls
<[email protected]>:

    Hi Marcus,


    I am calling MATLAB compiled code from within GNURadio C++ blocks.
    MATLAB compiled code uses a specific version of Boost, and they are
    still using 1.49, even with their latest release. I get a the trace
    below when I try to run the MATLAB code on newer
    GNURadio/Ubuntu/Boost though it works fine on my old
    (ancient) GNURadio/Ubuntu/Boost​ build where the Boost versions
    match. (Also included is MathWorks take on it).


    I was reticent to give all the details because previous MATLAB
    questions have left the community running for the hills, saying I
    should write everything directly in C++ etc, but there are lots of
    reasons we can't do this, for now!


    Thanks,


    David





    (python2:16446): IBUS-WARNING **: The owner of
    /home/gnuradio/.config/ibus/bus is not root!
    Using Volk machine: avx_64_mmx_orc
    Attempting to initialise the MCR application...
    Attempting to initialise the libdla application...

    ------------------------------------------------------------------------
           Segmentation violation detected at Tue Jun 23 15:25:36 2015
    ------------------------------------------------------------------------

    Configuration:
      Crash Decoding     : Disabled
      Default Encoding   : UTF-8
      GNU C Library      : 2.19 stable
      MATLAB Architecture: glnxa64
      MATLAB Root        : /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81
      MATLAB Version     : 8.1.0.604 (R2013a)
      Operating System   : Linux 3.13.0-32-generic #57-Ubuntu SMP Tue
    Jul 15 03:51:08 UTC 2014 x86_64
      Processor ID       : x86 Family 6 Model 60 Stepping 3, GenuineIntel

    Fault Count: 1


    Abnormal termination:
    Segmentation violation

    Register State (from fault):
      RAX = 00000000049dd7f0  RBX = 00000000049dd820
      RCX = 0000000000000002  RDX = 0000000000000000
      RSP = 00007fff0de311e0  RBP = 0000000000000001
      RSI = 0000000000000000  RDI = 0000000000000001

       R8 = 00000000049dd820   R9 = 0000000000000000
      R10 = 000000000000069c  R11 = a3d70a3d70a3d70b
      R12 = 00000000ffffffff  R13 = 00007fff0de31450
      R14 = 000000000494e448  R15 = 000000000494e2f8

      RIP = 00007f1ee264a414  EFL = 0000000000010202

       CS = 0033   FS = 0000   GS = 0000

    Stack Trace (from fault):
    [  0] 0x00007f1ee264a414            
     /lib/x86_64-linux-gnu/libpthread.so.0+00042004
    pthread_mutex_lock+00000004
    [  1] 0x00007f1ede8b37fa
    /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.54.0+00047098
    _ZN5boost6thread9interruptEv+00000074
    [  2] 0x00007f1e9cec7b25
    
/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwdservices.so+00146213
    [  3] 0x00007f1e9ced7c76
    
/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwdservices.so+00212086
    _ZN10dsLockFileD1Ev+00000038
    [  4] 0x00007f1e9cece93a
    
/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwdservices.so+00174394
    _ZN5boost6detail17sp_counted_impl_pI10dsLockFileE7disposeEv+00000026
    [  5] 0x00007f1ebc46e379
    /usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmat.so+00091001
    _ZN5boost6detail12shared_countD1Ev+00000073
    [  6] 0x00007f1e9ced3d40
    
/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwdservices.so+00195904
    
_ZN24dsDirectoryExclusiveLock7releaseERKN5boost10posix_time13time_durationE+00000176
    [  7] 0x00007f1e9ced3d9f
    
/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwdservices.so+00195999
    _ZN24dsDirectoryExclusiveLock7releaseEv+00000031
    [  8] 0x00007f1e9cecdf8c
    
/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwdservices.so+00171916
    
_ZN24dsDirectoryReadWriteLock8ReadLock4Impl7acquireERKN5boost10posix_time13time_durationEb+00001276
    [  9] 0x00007f1e9cece3e6
    
/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwdservices.so+00173030
    _ZN24dsDirectoryReadWriteLock8ReadLock7acquireEb+00000038
    [ 10] 0x00007f1e8d45c602
    
/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwmclmcr.so+01230338
    [ 11] 0x00007f1e8d3ee718
    
/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwmclmcr.so+00780056
    [ 12] 0x00007f1e8d3ef2d6
    
/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwmclmcr.so+00783062
    
_ZN5boost6detail8function21function_obj_invoker0INS_3_bi6bind_tINS_10shared_ptrI21mclExtractedComponentEEPFS7_N6mclmcr12CtfExtractorEENS3_5list1INS3_5valueIS9_EEEEEES7_E6invokeERNS1_15function_bufferE+00000054
    [ 13] 0x00007f1e8d42df95
    
/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwmclmcr.so+01040277
    
_Z30mclInitializeComponentInstanceRKN5boost8functionIFiPKcEEES6_NS_9function0INS_10shared_ptrI21mclExtractedComponentEEEE+00000389
    [ 14] 0x00007f1e8d3f9c0d
    
/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64/libmwmclmcr.so+00826381
    mclInitializeComponentInstanceEmbedded+00000573
    [ 15] 0x00007f1ec645c763
    
/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/runtime/glnxa64/libmwmclmcrrt.so.8.1+00124771
    mclInitializeComponentInstanceEmbedded_proxy+00000067
    [ 16] 0x00007f1ec5c2c1eb
    /home/gnuradio/gnuradio_trlcode/gr-trl/lib/libdla.so+00008683
    libdlaInitializeWithHandlers+00000107
    [ 17] 0x00007f1ec5c2c22b
    /home/gnuradio/gnuradio_trlcode/gr-trl/lib/libdla.so+00008747
    libdlaInitialize+00000023
    [ 18] 0x00007f1ec6c3393d                
     /usr/local/lib/libgnuradio-trl.so+00493885
    [ 19] 0x00007f1ec6c33e08                
     /usr/local/lib/libgnuradio-trl.so+00495112
    _ZN2gr3trl5dla_r4makeEiiibbfb+00000104
    [ 20] 0x00007f1ec70bb740
    /usr/local/lib/python2.7/dist-packages/trl/_trl_swig.so+02164544
    [ 21] 0x000000000052c6d5                                  
    /usr/bin/python2+01230549 PyEval_EvalFrameEx+00001061
    [ 22] 0x000000000055c594                                  
    /usr/bin/python2+01426836 PyEval_EvalCodeEx+00000676
    [ 23] 0x000000000052ca8d                                  
    /usr/bin/python2+01231501 PyEval_EvalFrameEx+00002013
    [ 24] 0x000000000056d0aa                                  
    /usr/bin/python2+01495210
    [ 25] 0x00000000004d9854                                  
    /usr/bin/python2+00890964
    [ 26] 0x00000000004d8379                                  
    /usr/bin/python2+00885625
    [ 27] 0x00000000004f5d0b                                  
    /usr/bin/python2+01006859
    [ 28] 0x000000000052cc20                                  
    /usr/bin/python2+01231904 PyEval_EvalFrameEx+00002416
    [ 29] 0x000000000055c594                                  
    /usr/bin/python2+01426836 PyEval_EvalCodeEx+00000676
    [ 30] 0x00000000005b7392                                  
    /usr/bin/python2+01799058 PyEval_EvalCode+00000050
    [ 31] 0x0000000000469663                                  
    /usr/bin/python2+00431715
    [ 32] 0x00000000004699e3                                  
    /usr/bin/python2+00432611 PyRun_FileExFlags+00000146
    [ 33] 0x0000000000469f1c                                  
    /usr/bin/python2+00433948 PyRun_SimpleFileExFlags+00000750
    [ 34] 0x000000000046ab81                                  
    /usr/bin/python2+00437121 Py_Main+00002910
    [ 35] 0x00007f1ee229cec5                  
     /lib/x86_64-linux-gnu/libc.so.6+00138949 __libc_start_main+00000245
    [ 36] 0x000000000057497e                                  
    /usr/bin/python2+01526142


    If this problem is reproducible, please submit a Service Request via:
        http://www.mathworks.com/support/contact_us/

    A technical support engineer might contact you with further information.

    Thank you for your help.** This crash report has been saved to disk
    as /home/gnuradio/matlab_crash_dump.16446-1 **



    MATLAB is exiting because of fatal error

    >>> Done​



    "The stack trace strongly suggests that the crash is related to a
    Boost library version conflict. MATLAB R2013a/MCR v8.1 includes and
    depends on Boost 1.49 libraries. In the stack trace we see that in
    practice your system's Boost 1.54 libraries are being accessed however.

    These things may occur if you load a MATLAB Compiler Shared Library
    into an application which is already making use of this system Boost
    library.

    There are no quick/easy workarounds for such issues other than:

    1. Making sure that all components involved make use of the same
    Boost library versions, or

    2. Making sure that the components which require Boost statically
    link against the Boost version which they prefer, or

    3. Separating the different components which require Boost into
    separate applications.

    In further detail:

    Option 1: It looks like you are making use of GNU Radio from Python,
    I do believe that GNU Radio depends on Boost. You may be able to
    (re)compile GNU Radio to make it use Boost 1.49 and where you even
    specifically link it to the Boost libraries shipped with the MCR
    (these can be found in the bin/glnxa64 directory).

    Option 2: If GNU Radio specifically requires a different Boost
    version you may be able to recompile it and statically link it
    against this version.

    Option 3: Instead of compiling your MATLAB Code into a Shared
    Library, compile it into a standalone application which you can
    launch from your Python process. This separate standalone should be
    able to use its own Boost libraries without problems then. There are
    Python libraries which can read and write MAT-files so you can
    relatively efficiently pass in- and outputs from and to that
    standalone application through MAT-files."



    ------------------------------------------------------------------------
    *From:*
    [email protected]
    <[email protected]> on
    behalf of Marcus Müller <[email protected]>
    *Sent:* 14 August 2015 17:59
    *To:* [email protected]
    *Subject:* Re: [Discuss-gnuradio] Building GNU Radio with previous
    Boost version
     
    Hi David,

    boost > 1.35 should work, but 1.49 is, if I remember correctly, an
    especially buggy version, especially in Ubuntu.
    I guess you wouldn't ask if there wasn't a problem, so maybe you
    want to elaborate?

    Best regards,
    Marcus

    On 08/14/2015 06:00 PM, David Halls wrote:
>
>     ​Hi guys,
>
>
>     For a number of complicated reasons I would like to build GNU
>     Radio with an older version of Boost. Specifically 1.49.
>
>
>     Thanks,
>
>
>     David
>
>
>     ------------------------------------------------------------------------
>
>     NOTE: The information in this email and any attachments may be
>     confidential and/or legally privileged. This message may be read,
>     copied and used only by the intended recipient. If you are not the
>     intended recipient, please destroy this message, delete any copies
>     held on your system and notify the sender immediately.
>
>     Toshiba Research Europe Limited, registered in England and Wales
>     (2519556). Registered Office 208 Cambridge Science Park, Milton
>     Road, Cambridge CB4 0GZ, England. Web: www.toshiba.eu/research/trl
>
>
>
>     ------------------------------------------------------------------------
>     This email has been scanned for email related threats and
>     delivered safely by Mimecast.
>     For more information please visit http://www.mimecast.com
>     ------------------------------------------------------------------------
>
>
>     _______________________________________________
>     Discuss-gnuradio mailing list
>     [email protected]
>     https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


    ------------------------------------------------------------------------

    NOTE: The information in this email and any attachments may be
    confidential and/or legally privileged. This message may be read,
    copied and used only by the intended recipient. If you are not the
    intended recipient, please destroy this message, delete any copies
    held on your system and notify the sender immediately.

    Toshiba Research Europe Limited, registered in England and Wales
    (2519556). Registered Office 208 Cambridge Science Park, Milton
    Road, Cambridge CB4 0GZ, England. Web: www.toshiba.eu/research/trl



    ------------------------------------------------------------------------
    This email has been scanned for email related threats and delivered
    safely by Mimecast.
    For more information please visit http://www.mimecast.com
    ------------------------------------------------------------------------

_______________________________________________
Discuss-gnuradio mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to