[MBDyn-users] Socket problems

Richard Crozier r.crozier at ed.ac.uk
Thu Oct 27 13:08:08 CEST 2016


Further to my previous messages, I have reduced my failing socket 
example to as small a file as possible.

Now there is just one mass and nothing else, no joints, no gravity, no 
forces except the external socket force.

When I run this, mbdyn aborts with the following message:

  StructExtForce(3001): recv() failed (got 52 of 56 bytes)

The test program (test_strext_socket) aborts with:

unknown cmd (0) from peer
*** Error in 
`/home/rcrozier/src/mbdyn-1.7.1/utils/.libs/lt-test_strext_socket': 
double free or corruption (out): 0x0000000001728050 ***
Aborted

If I run in MBDyn without the external socket force, I get no error.

Does anyone else see this? Is it a problem with my build? Am I maybe 
using test_strext_socket wrong?

Thanks,

Richard

On 19/10/16 11:43, Richard Crozier wrote:
>
> Apologies for sending many emails (it doesn't mean I expect immediate
> responses, just reporting things as I find them).
>
> To follow up on my previous emails, I still have trouble with the
> sockets. With the attached files I get the expected output if I do not
> use socket forces, but a memory error if I attempt to use sockets. To
> use socket forces, run the attached shell script which uses
> test_strext_socket to supply the forces). For me this gives the output:
>
> -----------------
> *** Starting MBDyn... PID=23954; sleeping 2 seconds...
> *** Starting test...
> iterations: 3
> cmd to peer: 7 (NEGOTIATION)
> cmd from peer: 8 (OK)
> cmd from peer: 2 (REGULAR_DATA)
> node #0 (2):
>     x=      +0.00000000e+00  +0.00000000e+00  +0.00000000e+00
>     R=      +1.00000000e+00  +0.00000000e+00  +0.00000000e+00
>             +0.00000000e+00  +1.00000000e+00  +0.00000000e+00
>             +0.00000000e+00  +0.00000000e+00  +1.00000000e+00
>     xp=     +0.00000000e+00  +0.00000000e+00  +0.00000000e+00
>     omega=  +0.00000000e+00  +0.00000000e+00  +0.00000000e+00
> cmd to peer: 2 (REGULAR_DATA)
> unknown cmd (0) from peer
> *** Error in
> `/home/rcrozier/src/mbdyn-1.7.1/utils/.libs/lt-test_strext_socket':
> double free or corruption (out): 0x0000000000a7a050 ***
> Aborted
> *** Done
> -----------------
>
> Alternatively, if I supply the -n argument to test_strext_socket, I do
> not get this error, but instead, I get an error about a mismatch in the
> orientation output (but it is specified in the file as 'orientation
> matrix', and in the call to test_strext_socket as '-R mat').
>
> -----------------
> [solver.cc,551]: creating solution vectors
> StructExtForce(3001): negotiation response failed: orientation output
> mismatch (local=512, remote=0)
> -----------------
>
> I've also tried using theta (and 'orientation vector' in the mbd file)
> and euler123, in all cases the 'local' value changed, but remote remains
> zero.
>
> Finally, if I comment out the socket forces (i.e. comment line 43 and
> lines 220 to 236) then launch mbdyn as normal:
>
> mbdyn -f heaving_buoy_socket_forces.mbd
>
> The problem is solved as normal with no error.
>
> I don't understand why the other examples (springmass and socket) work
> fine and this one does not, but also don't see any error in how I have
> set up the file, especially as it runs fine without the socket forces.
>
> Regards,
>
> Richard
>
>
>
> _______________________________________________
> MBDyn-users mailing list
> MBDyn-users at mbdyn.org
> https://mail.mbdyn.org/cgi-bin/mailman/listinfo/mbdyn-users
>

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

-------------- next part --------------
# minimal example of file producing socket comms error. When I run this,
# mbdyn aborts with the following message:
#
# StructExtForce(3001): recv() failed (got 52 of 56 bytes)
#
# The test program (test_strext_socket) aborts with:
#
#
# unknown cmd (0) from peer
# *** Error in `/home/rcrozier/src/mbdyn-1.7.1/utils/.libs/lt-test_strext_socket': double free or corruption (out): 0x0000000001728050 ***
# Aborted

begin: data;
    problem: initial value; # the default
end: data;

begin: initial value;
    initial time: 0.0;
    final time: 1.0;
    time step: 1.0e-2;

    max iterations: 10;
    tolerance: 1.0e-6;
    
    output: iterations, residual, solution, counter, bailout;

end: initial value;

begin: control data;
    
    structural nodes:
        +1    # node in the stator
    ;
    rigid bodies:
        +1    # node in the stator
    ;
    forces:
        +1    # socket
    ;
    
end: control data;

set: integer nd_stator_id = 3;
set: integer bd_stator_id = 1000+nd_stator_id;

set: real stator_d = 600.0e-3;
set: real stator_l = 1.0;
set: real stator_mass = pi * (stator_d/2.0)^2.0 * stator_l * 7500.0;

set: integer ref_stator = 4001;

reference: ref_stator,
    reference, global, null,
    reference, global, eye,
    reference, global, null,
    reference, global, null;

begin: nodes;
    structural: nd_stator_id, dynamic, 
        reference, ref_stator, null,  # relative position
        reference, ref_stator, eye,   # relative orientation
        reference, ref_stator, null,  # relative velocity
        reference, ref_stator, null;  # relative angular velocity

end: nodes;

set: real stator_Ixx = stator_mass * (3.*stator_d^2+stator_l^2)/12.;
set: real stator_Iyy = stator_mass * (3.*stator_d^2+stator_l^2)/12.;
set: real stator_Izz = stator_mass * (stator_d + stator_d)^2/8.0;

begin: elements;

    body: bd_stator_id, nd_stator_id,
      stator_mass,                      # mass
      null,                             # relative center of mass
      diag, stator_Ixx, stator_Iyy, stator_Izz; # inertia matrix

    set: integer fc_buoy_ext_id = 3001;
    # buoy force from external program, matlab in our case
    force: fc_buoy_ext_id, external structural,
        socket,                 # socket communicator
          create,
              yes,
          path,
              "/tmp/mbdyn.sock",
          no signal,
        coupling,
            tight,
            #loose,
        labels, 
            yes,
        orientation,
            orientation matrix,
        #    orientation vector,
        #    euler123,
        1,                      # number of nodes to receive forces
            nd_stator_id, offset, null,      # buoy
        echo, "heaving_buoy_socket_forces_minimal_config.txt";
    
    print symbol table;

end: elements;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: socket_error_minimal.sh
Type: application/x-shellscript
Size: 1584 bytes
Desc: not available
URL: <http://mail.mbdyn.org/pipermail/mbdyn-users/attachments/20161027/1590ee38/attachment.bin>
-------------- next part --------------
# minimal example of file producing socket comms error, but without the
# socket force to test in plain mbdyn
#
#

begin: data;
    problem: initial value; # the default
end: data;

begin: initial value;
    initial time: 0.0;
    final time: 1.0;
    time step: 1.0e-2;

    method: ms, 0.6;
    max iterations: 10;
    tolerance: 1.0e-6;
    
    output: iterations, residual, solution, counter, bailout;

end: initial value;

begin: control data;
    
    structural nodes:
        +1    # node in the stator
    ;
    rigid bodies:
        +1    # node in the stator
    ;
#    forces:
#        +1    # socket
#    ;
    
end: control data;

set: integer nd_stator_id = 3;
set: integer bd_stator_id = 1000+nd_stator_id;

set: real stator_d = 600.0e-3;
set: real stator_l = 1.0;
set: real stator_mass = pi * (stator_d/2.0)^2.0 * stator_l * 7500.0;

set: integer ref_stator = 4001;

reference: ref_stator,
    reference, global, null,
    reference, global, eye,
    reference, global, null,
    reference, global, null;


begin: nodes;
    structural: nd_stator_id, dynamic, 
        reference, ref_stator, null,  # relative position
        reference, ref_stator, eye,   # relative orientation
        reference, ref_stator, null,  # relative velocity
        reference, ref_stator, null;  # relative angular velocity

end: nodes;

set: real stator_Ixx = stator_mass * (3.*stator_d^2+stator_l^2)/12.;
set: real stator_Iyy = stator_mass * (3.*stator_d^2+stator_l^2)/12.;
set: real stator_Izz = stator_mass * (stator_d + stator_d)^2/8.0;

begin: elements;

    body: bd_stator_id, nd_stator_id,
      stator_mass,                      # mass
      null,                             # relative center of mass
      diag, stator_Ixx, stator_Iyy, stator_Izz; # inertia matrix
    
    print symbol table;

end: elements;


More information about the MBDyn-users mailing list