fzi-forschungszentrum-informatik / Lanelet2

Map handling framework for automated driving
BSD 3-Clause "New" or "Revised" License
800 stars 327 forks source link

TestBinHandler fails with ROS Noetic #128

Closed kenji-miyake closed 4 years ago

kenji-miyake commented 4 years ago

Hello, I found TestBinHandler fails on ROS Noetic. I suspect it's because some dependent libraries have destructive changes, but I'm not sure what they are.

Would you help me to solve this problem?

Environment

https://www.ros.org/reps/rep-0003.html#noetic-ninjemys-may-2020-may-2025

Problem

$ catkin_test_results --verbose

-------------------------------------------------
Full test results for 'build/test_results/lanelet2_io/gtest-lanelet2_io-gtest-TestBinHandler.xml'
-------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="10" failures="4" disabled="0" errors="0" time="0.164" timestamp="2020-05-31T16:48:14" name="AllTests">
  <testsuite name="Serialize" tests="1" failures="0" disabled="0" errors="0" time="0" timestamp="2020-05-31T16:48:14">
    <testcase name="Attribute" status="run" result="completed" time="0" timestamp="2020-05-31T16:48:14" classname="Serialize" />
  </testsuite>
  <testsuite name="SerializeTest" tests="5" failures="3" disabled="0" errors="0" time="0.007" timestamp="2020-05-31T16:48:14">
    <testcase name="Point" status="run" result="completed" time="0.001" timestamp="2020-05-31T16:48:14" classname="SerializeTest" />
    <testcase name="Regelem" status="run" result="completed" time="0.001" timestamp="2020-05-31T16:48:14" classname="SerializeTest">
      <failure message="unknown file&#x0A;C++ exception with description &quot;No traffic light defined!&quot; thrown in the test body." type=""><![CDATA[unknown file
C++ exception with description "No traffic light defined!" thrown in the test body.]]></failure>
    </testcase>
    <testcase name="Lanelet" status="run" result="completed" time="0" timestamp="2020-05-31T16:48:14" classname="SerializeTest" />
    <testcase name="Area" status="run" result="completed" time="0.001" timestamp="2020-05-31T16:48:14" classname="SerializeTest">
      <failure message="unknown file&#x0A;C++ exception with description &quot;No traffic light defined!&quot; thrown in the test body." type=""><![CDATA[unknown file
C++ exception with description "No traffic light defined!" thrown in the test body.]]></failure>
    </testcase>
    <testcase name="LaneletMap" status="run" result="completed" time="0.004" timestamp="2020-05-31T16:48:14" classname="SerializeTest">
      <failure message="unknown file&#x0A;C++ exception with description &quot;No traffic light defined!&quot; thrown in the test body." type=""><![CDATA[unknown file
C++ exception with description "No traffic light defined!" thrown in the test body.]]></failure>
    </testcase>
  </testsuite>
  <testsuite name="OsmHandler" tests="1" failures="0" disabled="0" errors="0" time="0.001" timestamp="2020-05-31T16:48:14">
    <testcase name="LaneletWithCenterline" status="run" result="completed" time="0.001" timestamp="2020-05-31T16:48:14" classname="OsmHandler" />
  </testsuite>
  <testsuite name="BinHandler" tests="3" failures="1" disabled="0" errors="0" time="0.156" timestamp="2020-05-31T16:48:14">
    <testcase name="extension" status="run" result="completed" time="0" timestamp="2020-05-31T16:48:14" classname="BinHandler" />
    <testcase name="explicitIO" status="run" result="completed" time="0.001" timestamp="2020-05-31T16:48:14" classname="BinHandler" />
    <testcase name="fullMap" status="run" result="completed" time="0.155" timestamp="2020-05-31T16:48:14" classname="BinHandler">
      <failure message="unknown file&#x0A;C++ exception with description &quot;No traffic light defined!&quot; thrown in the test body." type=""><![CDATA[unknown file
C++ exception with description "No traffic light defined!" thrown in the test body.]]></failure>
    </testcase>
  </testsuite>
</testsuites>

How to reproduce the problem

$ mkdir -p ~/lanelet2_ws/src
$ cd ~/lanelet2_ws/src
$ git clone git@github.com:fzi-forschungszentrum-informatik/Lanelet2.git
$ git clone git@github.com:KIT-MRT/mrt_cmake_modules.git
$ docker run -it -v $HOME/lanelet2_ws:/lanelet2_ws osrf/ros:noetic-desktop-full

# cd /lanelet2_ws
# apt update && apt install -y python-is-python3
# rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO
# catkin_make test
# catkin_test_results --verbose
poggenhans commented 4 years ago

Thanks for the detailed issue description. That was a tough one. Apparently boost::serialization assumes that when two objects are serialized that have the same address, they must be identical. That goes wrong If the first object went out of scope in the process of serialization and the second object just happens to reuse the address of the first one.

The problem seems to happen with every version of boost, however when the compiler changes or is configured differently, the memory layout changes and the error disappears.

I fixed that now by making sure that no object that is serialized lives on the stack, but I am not sure if this behavior of boost is intentional.

poggenhans commented 4 years ago

Actually it turned out to be a bug in boost::serialization with boost::variant. I opened an issue there.