gazebosim / sdformat

Simulation Description Format (SDFormat) parser and description files.
http://sdformat.org
Apache License 2.0
169 stars 97 forks source link

bad_any_cast after Element::GetAny with gz11 on homebrew #202

Open osrf-migration opened 6 years ago

osrf-migration commented 6 years ago

Original report (archived issue) by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


There are two failing tests for the gz11 branch on macOS mojave.

I started by investigating the GetAny test failure from UNIT_SDF_TEST, which failed at line 418, which occurs when a std::bad_any_cast is thrown after calling std::any_cast<ignition::math::Pose3d>(anyValue). I added some print statements to confirm that anyValue should have the right type:

diff -r 3826e3878b15598634df332d0c93f7186a506f49 src/SDF_TEST.cc
--- a/src/SDF_TEST.cc   Fri Sep 14 00:49:58 2018 +0000
+++ b/src/SDF_TEST.cc   Thu Sep 13 17:59:35 2018 -0700
@@ -410,6 +410,13 @@
     std::any anyValue = poseElem->GetAny();
     try
     {
+      using Pose = ignition::math::Pose3d;
+      std::cerr << typeid(Pose).name()
+                << ", " << typeid(Pose).hash_code()
+                << std::endl;
+      std::cerr << anyValue.type().name()
+                << ", " << anyValue.type().hash_code()
+                << std::endl;
       EXPECT_EQ(std::any_cast<ignition::math::Pose3d>(anyValue),
           ignition::math::Pose3d(0, 1, 2, 0, 0, 0));
     }

which gives the following output, showing that the types have matching names, but different hash_codes.

[ RUN      ] SDF.GetAny
N8ignition4math2v65Pose3IdEE, 4381304960
N8ignition4math2v65Pose3IdEE, 4382335968
/Users/jenkins/workspace/sdformat-ci-pr_any-homebrew-amd64-mojave/sdformat/src/SDF_TEST.cc:425: Failure
Failed
[  FAILED  ] SDF.GetAny (57 ms)

After some googling, I found an issue with clang with a reproducible test case (that was originally reported on stackoverflow). I think it's an issue with std::any in clang, because the reproducible test case works with gcc or if you switch from std::any to boost::any.

I think we see the issue because ignition::math::Pose3d is a template type, and it may be seeing different versions of of that type from different shared libraries and not recognizing that they are the same. I have requested a llvm.org account so that I can comment on that issue.

osrf-migration commented 5 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


disabling failed tests in pull request #511

scpeters commented 4 years ago

it looks like this is fixed in macOS catalina?

scpeters commented 4 years ago

This has been fixed in Xcode 12+ available on macOS 10.15 Catalina

scpeters commented 4 years ago

tests enabled for Xcode 12+ in https://github.com/osrf/sdformat/pull/414

scpeters commented 3 years ago

this was passing CI and now it's failing; I don't know why, but I'm disabling the tests again