boost asio Io_server problem

Issue #41 on hold
Former user created an issue

I get a segmentation fault when I use trac_ik at:

std::size_t io_service::run() { boost::system::error_code ec; std::size_t s = impl_.run(ec); boost::asio::detail::throw_error(ec); return s; }

"Works" if I comment out in trac_ik.cpp: initialize() ...

// threads.create_thread(boost::bind(&boost::asio::io_service::run, // &io_service)); // threads.create_thread(boost::bind(&boost::asio::io_service::run, // &io_service));

Seen this before?

Observations: * I noticed if I single stepped real slow in Netbeans it didn't bomb. * I tried to catch exception, but couldn't * I don't use boost asio in this ROS package. I have had problems with boost asio io_server in other ROS packages so I know its prickly.

TIA, John

Official response

Comments (20)

  1. Patrick Beeson Account Deactivated

    I've never heard of anyone else having this issue.

    1) whats the OS/ROS version you are using? 2) can you install the tracik deb files and reproduce the segfault?

  2. John Michaloski

    ROS indigo on ubuntu 14.04

    I am not using moveit so trac_ik is not a plugin. I downloaded code and made into local package.

    I am used to boost asio issues with io_server.

    Thanks for you help.

  3. Patrick Beeson Account Deactivated

    This was originally built for 14.04 indigo. No one has seeen these issues in many thousands of hours of testing/usage.

    Are you using the standard indigo Boost libraries that compile via apt?

    Could you help me diagnose by removing trac-ik from your catkin workspace, installing ros-indigo-trac-ik via apt, and link your application against that?

  4. John Michaloski

    Removed locally. Same issue with io_server. Already had latest version of trac-ik in ROS.

    michalos@woodsy:nistfanuc_ws> sudo apt-get install ros-indigo-trac-ik Reading package lists... Done Building dependency tree
    Reading state information... Done ros-indigo-trac-ik is already the newest version.

    I am not CMake guru, so commented this line out in CMakeLists.txt: set(CMAKE_CXX_FLAGS "-DBOOST_LOG_DYN_LINK ${CMAKE_CXX_FLAGS}")

    boost version (from include file) installed from ROS (I think) - old version for sure: #define BOOST_LIB_VERSION "1_54"

    Anyway, like I mentioned I have had issues with io_server.run before. But it was only with one asio thread, and ran ok if io_server.run in main thread.

  5. Patrick Beeson Account Deactivated

    Is there a way you can help me reproduce this deterministically on my machine?

    i.e. send me your test case?

    Can you run the trac-ik example without this issue?

  6. John Michaloski

    We are using trac_ik as one of a couple motoman FK/IK solvers.

    The thing that faults is the boost asio run threads in trak_ic.cpp

    The code is not quite spaghetti but there are meatballs so that I will develop a small trac_ik test case.

  7. John Michaloski

    When I pare down the ROS workspace to a minimum, the trac_ik spawning of boost asio io_server threads works fine.

  8. Patrick Beeson Account Deactivated

    We are using this as part of a larger Motoman-based provision system and have seen no problems. This uses trac-ik as a library in a planner inside a plugin. No issues. Perhaps something about your larger system is clobbering memory?

  9. Diogo Almeida

    Hi! I just tried to use trac_ik on my machine (ROS Indigo + Ubuntu 14.04) and I have exactly the same issue with a segfault when the threads the OP mentioned are created.

    I have no idea on how to help you debug this, but I am willing to try. Right now my solution was to disable the threads and call the solvers sequentially.

  10. Patrick Beeson Account Deactivated

    Does this happen when you install via apt-get install ros-indigo-trac-ik ?

  11. Patrick Beeson Account Deactivated

    Hmm. So the previous discussion indicates that when they paired down their program to a simpler form this went away. We haven't seen this in many hours of testing, so I'm wondering again is if there isn't something in your larger program that might be stepping on memory.

    Or perhaps there is an issue in the boost versions in 14.04?

    In any case, it people are willing to use c++-11 or higher, it might be worthwhile just switching to C++ futures instead of the boost asio stuff.

  12. Diogo Almeida

    I will try to just run the test examples that come in the repository and check if I still get this issue.

  13. Diogo Almeida

    The tests run without an issue. I'll try to figure out what are the differences in my code that lead to this segfault and I'll post back once I have an answer.

  14. John Michaloski

    I never resolved multithreading issue. Used ikfast instead in larger apps (not with moveit). Trac ik worked fine in test programs.

  15. Patrick Beeson Account Deactivated

    Oh yes, KDL is certainly not thread safe so you can’t make concurrent call to trac-IK solver from multiple threads.

  16. Patrick Beeson Account Deactivated

    I guess I could add mutexes inside the public methods and make the class a singleton so that any multi-threaded application would work without changes.

  17. Log in to comment