Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transition_vtol_fixed_wing example never ready to arm #401

Closed
hamishwillee opened this issue May 21, 2018 · 1 comment
Closed

transition_vtol_fixed_wing example never ready to arm #401

hamishwillee opened this issue May 21, 2018 · 1 comment
Assignees
Labels

Comments

@hamishwillee
Copy link
Collaborator

hamishwillee commented May 21, 2018

This example is never ready to arm. Running it sometimes gets a segmentation fault.

$ ./transition_vtol_fixed_wing udp://:14540
Waiting to discover system...
[03:18:46|Info ] New device on: 127.0.0.1:14557 (udp_connection.cpp:208)
[03:18:46|Debug] New: System ID: 1 Comp ID: 1 (dronecore_impl.cpp:286)
[03:18:46|Debug] Component Autopilot added. (mavlink_system.cpp:330)
[03:18:46|Debug] MAVLink: info: data link #1 lost (mavlink_system.cpp:267)
[03:18:46|Debug] MAVLink: info: data link #1 regained (mavlink_system.cpp:267)
[03:18:46|Debug] Found 1 component(s). (mavlink_system.cpp:462)
[03:18:46|Debug] Discovered 4294967298 (mavlink_system.cpp:464)
Discovered system with UUID: 4294967298
[03:18:46|Debug] We got an ack: 520 (mavlink_commands.cpp:140)
[03:18:48|Debug] We got an ack: 511 (mavlink_commands.cpp:140)
Vehicle not ready to arm
Segmentation fault (core dumped)

I changed the arm test code such that it retries the health check:

// Check if vehicle is ready to arm
while (telemetry->health_all_ok() != true) {
std::cout << ERROR_CONSOLE_TEXT << "Vehicle not ready to arm" << NORMAL_CONSOLE_TEXT << std::endl;
sleep_for(std::chrono::seconds(1));
}

In this case I got it ready to arm after 1 second. But then it fails with landed state unknown.

Vehicle not ready to arm
Altitude: 0.044 m
Arming...
Arming failed:Command denied, landed state is unknown

BUT, if I change nothing and just run the takeoff_and_land example it will takeoff and land. No problems with arming at all.

@julianoes
Copy link
Collaborator

@hamishwillee thanks for reporting. I can reproduce this:

valgrind ./transition_vtol_fixed_wing
==11685== Memcheck, a memory error detector
==11685== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==11685== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==11685== Command: ./transition_vtol_fixed_wing
==11685== 
Waiting to discover system...
[09:44:40|Info ] New device on: 127.0.0.1:14557 (udp_connection.cpp:208)
[09:44:40|Debug] New: System ID: 1 Comp ID: 1 (dronecore_impl.cpp:286)
[09:44:40|Debug] Component Autopilot added. (mavlink_system.cpp:338)
[09:44:41|Debug] MAVLink: info: data link #0 lost (mavlink_system.cpp:275)
[09:44:41|Debug] MAVLink: info: data link #0 regained (mavlink_system.cpp:275)
[09:44:41|Debug] Found 1 component(s). (mavlink_system.cpp:470)
[09:44:41|Debug] Discovered 4294967298 (mavlink_system.cpp:472)
Discovered system with UUID: 4294967298
Vehicle not ready to arm
==11685== Thread 2:
==11685== Invalid read of size 2
==11685==    at 0x4F0BD7D: dronecore::MAVLinkSystem::process_mavlink_message(__mavlink_message const&) (mavlink_system.cpp:130)
==11685==    by 0x4F095D7: dronecore::System::process_mavlink_message(__mavlink_message const&) (system.cpp:58)
==11685==    by 0x4F18AA0: dronecore::DroneCoreImpl::receive_message(__mavlink_message const&) (dronecore_impl.cpp:82)
==11685==    by 0x4F071AA: dronecore::Connection::receive_message(__mavlink_message const&) (connection.cpp:42)
==11685==    by 0x4F433CA: dronecore::UdpConnection::receive(dronecore::UdpConnection*) (udp_connection.cpp:227)
==11685==    by 0x4F43760: void std::__invoke_impl<void, void (*)(dronecore::UdpConnection*), dronecore::UdpConnection*>(std::__invoke_other, void (*&&)(dronecore::UdpConnection*), dronecore::UdpConnection*&&) (invoke.h:60)
==11685==    by 0x4F434A2: std::__invoke_result<void (*)(dronecore::UdpConnection*), dronecore::UdpConnection*>::type std::__invoke<void (*)(dronecore::UdpConnection*), dronecore::UdpConnection*>(void (*&&)(dronecore::UdpConnection*), dronecore::UdpConnection*&&) (invoke.h:95)
==11685==    by 0x4F43A0E: decltype (__invoke((_S_declval<0ul>)(), (_S_declval<1ul>)())) std::thread::_Invoker<std::tuple<void (*)(dronecore::UdpConnection*), dronecore::UdpConnection*> >::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) (thread:234)
==11685==    by 0x4F439C9: std::thread::_Invoker<std::tuple<void (*)(dronecore::UdpConnection*), dronecore::UdpConnection*> >::operator()() (thread:243)
==11685==    by 0x4F439AD: std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(dronecore::UdpConnection*), dronecore::UdpConnection*> > >::_M_run() (thread:186)
==11685==    by 0x569C512: ??? (in /usr/lib64/libstdc++.so.6.0.25)
==11685==    by 0x62E1563: start_thread (in /usr/lib64/libpthread-2.27.so)
==11685==  Address 0xadf1530 is 0 bytes after a block of size 768 alloc'd
==11685==    at 0x4C2E226: operator new(unsigned long) (vg_replace_malloc.c:334)
==11685==    by 0x4F15BD8: __gnu_cxx::new_allocator<dronecore::MAVLinkSystem::MAVLinkHandlerTableEntry>::allocate(unsigned long, void const*) (new_allocator.h:111)
==11685==    by 0x4F14CB9: std::allocator_traits<std::allocator<dronecore::MAVLinkSystem::MAVLinkHandlerTableEntry> >::allocate(std::allocator<dronecore::MAVLinkSystem::MAVLinkHandlerTableEntry>&, unsigned long) (alloc_traits.h:436)
==11685==    by 0x4F1359D: std::_Vector_base<dronecore::MAVLinkSystem::MAVLinkHandlerTableEntry, std::allocator<dronecore::MAVLinkSystem::MAVLinkHandlerTableEntry> >::_M_allocate(unsigned long) (stl_vector.h:296)
==11685==    by 0x4F11A89: void std::vector<dronecore::MAVLinkSystem::MAVLinkHandlerTableEntry, std::allocator<dronecore::MAVLinkSystem::MAVLinkHandlerTableEntry> >::_M_realloc_insert<dronecore::MAVLinkSystem::MAVLinkHandlerTableEntry const&>(__gnu_cxx::__normal_iterator<dronecore::MAVLinkSystem::MAVLinkHandlerTableEntry*, std::vector<dronecore::MAVLinkSystem::MAVLinkHandlerTableEntry, std::allocator<dronecore::MAVLinkSystem::MAVLinkHandlerTableEntry> > >, dronecore::MAVLinkSystem::MAVLinkHandlerTableEntry const&) (vector.tcc:427)
==11685==    by 0x4F0FBCF: std::vector<dronecore::MAVLinkSystem::MAVLinkHandlerTableEntry, std::allocator<dronecore::MAVLinkSystem::MAVLinkHandlerTableEntry> >::push_back(dronecore::MAVLinkSystem::MAVLinkHandlerTableEntry const&) (stl_vector.h:1085)
==11685==    by 0x4F0BB38: dronecore::MAVLinkSystem::register_mavlink_message_handler(unsigned short, std::function<void (__mavlink_message const&)>, void const*) (mavlink_system.cpp:81)
==11685==    by 0x53CB6C1: dronecore::TelemetryImpl::init() (telemetry_impl.cpp:69)
==11685==    by 0x4F0E3BE: dronecore::MAVLinkSystem::register_plugin(dronecore::PluginImplBase*) (mavlink_system.cpp:856)
==11685==    by 0x53CB3D0: dronecore::TelemetryImpl::TelemetryImpl(dronecore::System&) (telemetry_impl.cpp:53)
==11685==    by 0x53C8C6E: dronecore::Telemetry::Telemetry(dronecore::System&) (telemetry.cpp:11)
==11685==    by 0x409B9E: void __gnu_cxx::new_allocator<dronecore::Telemetry>::construct<dronecore::Telemetry, dronecore::System&>(dronecore::Telemetry*, dronecore::System&) (in /home/julianoes/src/DroneCore/example/transition_vtol_fixed_wing/build/transition_vtol_fixed_wing)
==11685== 
==11685== Conditional jump or move depends on uninitialised value(s)
==11685==    at 0x4F0BDA8: dronecore::MAVLinkSystem::process_mavlink_message(__mavlink_message const&) (mavlink_system.cpp:130)
==11685==    by 0x4F095D7: dronecore::System::process_mavlink_message(__mavlink_message const&) (system.cpp:58)
==11685==    by 0x4F18AA0: dronecore::DroneCoreImpl::receive_message(__mavlink_message const&) (dronecore_impl.cpp:82)
==11685==    by 0x4F071AA: dronecore::Connection::receive_message(__mavlink_message const&) (connection.cpp:42)
==11685==    by 0x4F433CA: dronecore::UdpConnection::receive(dronecore::UdpConnection*) (udp_connection.cpp:227)
==11685==    by 0x4F43760: void std::__invoke_impl<void, void (*)(dronecore::UdpConnection*), dronecore::UdpConnection*>(std::__invoke_other, void (*&&)(dronecore::UdpConnection*), dronecore::UdpConnection*&&) (invoke.h:60)
==11685==    by 0x4F434A2: std::__invoke_result<void (*)(dronecore::UdpConnection*), dronecore::UdpConnection*>::type std::__invoke<void (*)(dronecore::UdpConnection*), dronecore::UdpConnection*>(void (*&&)(dronecore::UdpConnection*), dronecore::UdpConnection*&&) (invoke.h:95)
==11685==    by 0x4F43A0E: decltype (__invoke((_S_declval<0ul>)(), (_S_declval<1ul>)())) std::thread::_Invoker<std::tuple<void (*)(dronecore::UdpConnection*), dronecore::UdpConnection*> >::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) (thread:234)
==11685==    by 0x4F439C9: std::thread::_Invoker<std::tuple<void (*)(dronecore::UdpConnection*), dronecore::UdpConnection*> >::operator()() (thread:243)
==11685==    by 0x4F439AD: std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(dronecore::UdpConnection*), dronecore::UdpConnection*> > >::_M_run() (thread:186)
==11685==    by 0x569C512: ??? (in /usr/lib64/libstdc++.so.6.0.25)
==11685==    by 0x62E1563: start_thread (in /usr/lib64/libpthread-2.27.so)
==11685== 
==11685== 
==11685== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==11685==  Bad permissions for mapped region at address 0xB1D8020
==11685==    at 0x4F0BD7D: dronecore::MAVLinkSystem::process_mavlink_message(__mavlink_message const&) (mavlink_system.cpp:130)
==11685==    by 0x4F095D7: dronecore::System::process_mavlink_message(__mavlink_message const&) (system.cpp:58)
==11685==    by 0x4F18AA0: dronecore::DroneCoreImpl::receive_message(__mavlink_message const&) (dronecore_impl.cpp:82)
==11685==    by 0x4F071AA: dronecore::Connection::receive_message(__mavlink_message const&) (connection.cpp:42)
==11685==    by 0x4F433CA: dronecore::UdpConnection::receive(dronecore::UdpConnection*) (udp_connection.cpp:227)
==11685==    by 0x4F43760: void std::__invoke_impl<void, void (*)(dronecore::UdpConnection*), dronecore::UdpConnection*>(std::__invoke_other, void (*&&)(dronecore::UdpConnection*), dronecore::UdpConnection*&&) (invoke.h:60)
==11685==    by 0x4F434A2: std::__invoke_result<void (*)(dronecore::UdpConnection*), dronecore::UdpConnection*>::type std::__invoke<void (*)(dronecore::UdpConnection*), dronecore::UdpConnection*>(void (*&&)(dronecore::UdpConnection*), dronecore::UdpConnection*&&) (invoke.h:95)
==11685==    by 0x4F43A0E: decltype (__invoke((_S_declval<0ul>)(), (_S_declval<1ul>)())) std::thread::_Invoker<std::tuple<void (*)(dronecore::UdpConnection*), dronecore::UdpConnection*> >::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) (thread:234)
==11685==    by 0x4F439C9: std::thread::_Invoker<std::tuple<void (*)(dronecore::UdpConnection*), dronecore::UdpConnection*> >::operator()() (thread:243)
==11685==    by 0x4F439AD: std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(dronecore::UdpConnection*), dronecore::UdpConnection*> > >::_M_run() (thread:186)
==11685==    by 0x569C512: ??? (in /usr/lib64/libstdc++.so.6.0.25)
==11685==    by 0x62E1563: start_thread (in /usr/lib64/libpthread-2.27.so)
==11685== 
==11685== HEAP SUMMARY:
==11685==     in use at exit: 7,456 bytes in 46 blocks
==11685==   total heap usage: 205 allocs, 159 frees, 99,964 bytes allocated
==11685== 
==11685== LEAK SUMMARY:
==11685==    definitely lost: 0 bytes in 0 blocks
==11685==    indirectly lost: 0 bytes in 0 blocks
==11685==      possibly lost: 1,680 bytes in 5 blocks
==11685==    still reachable: 5,776 bytes in 41 blocks
==11685==         suppressed: 0 bytes in 0 blocks
==11685== Rerun with --leak-check=full to see details of leaked memory
==11685== 
==11685== For counts of detected and suppressed errors, rerun with: -v
==11685== Use --track-origins=yes to see where uninitialised values come from
==11685== ERROR SUMMARY: 85216 errors from 2 contexts (suppressed: 0 from 0)
[1]    11685 segmentation fault (core dumped)  valgrind ./transition_vtol_fixed_wing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants