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

BodyNode::createShapeNodeWith() access violation on Windows 10 #1431

Closed
koonyook opened this issue Jan 19, 2020 · 5 comments
Closed

BodyNode::createShapeNodeWith() access violation on Windows 10 #1431

koonyook opened this issue Jan 19, 2020 · 5 comments
Labels
type: bug Indicates an unexpected problem or unintended behavior

Comments

@koonyook
Copy link

I previously used DART on Ubuntu and it works fine with this C++ piece of code I have. However, I need to bring some of my code to Windows 10. The compilation of DART and my project on VS2019 went well. Unfortunately, a line of code produces an access violation error during runtime.

This is the independent code section that causes the problem

dart::dynamics::SkeletonPtr skel = dart::dynamics::Skeleton::create("abc");
dart::dynamics::BodyNode *parent = nullptr;
dart::dynamics::Joint::Properties *joint_properties = MASS::MakeFreeJointProperties("def", Eigen::Isometry3d::Identity(), Eigen::Isometry3d::Identity());
dart::dynamics::FreeJoint::Properties *prop = dynamic_cast<dart::dynamics::FreeJoint::Properties*>(joint_properties);
dart::dynamics::BodyNode *bn = skel->createJointAndBodyNodePair<dart::dynamics::FreeJoint>(
	parent, (*prop), dart::dynamics::BodyNode::AspectProperties(joint_properties->mName)
	).second;
Eigen::Vector3d size;
size << 1, 1, 1;
dart::dynamics::ShapePtr shape = std::shared_ptr<dart::dynamics::BoxShape>(new dart::dynamics::BoxShape(size));;
bn->createShapeNodeWith<dart::dynamics::VisualAspect>(shape);  //access violation here

This is the error log.
Exception thrown at 0x00007FFBA46F7319 (vcruntime140d.dll) in ConsoleApplication1.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

By tracing, I've found that the error occurs in FixedFrame.cpp in the createAspect()

FixedFrame::FixedFrame(Frame* refFrame,
                       const Eigen::Isometry3d& relativeTransform)
  : Entity(refFrame, false),
    Frame(refFrame)
{
  createAspect<Aspect>(AspectProperties(relativeTransform)); // runtime error at this line
}

And the last tracable line is in Aspect.hpp during the dynamic_cast of function setComposite()

mComposite = dynamic_cast<CompositeType*>(newComposite);

At this line, The FixedFrame object inside the newComposite seems to point to nowhere as the debugger is unable to read the memory inside that object.

As it is related to dynamic_cast, Run-Time Type Information (/GR) has been enabled but the problem still exist.

Bug Report

Please answer the following questions for yourself before reporting a bug.

  • [Y] I checked the documentation and the forum but found no answer.
  • [Y] I checked to make sure that this issue has not already been filed.

Environment

Select the following information.

  • DART version: 6.9.2 (stable release) with all the library from vcpkg (according to http://dartsim.github.io/install_dart_on_windows.html)
  • OS name and version name(or number): Windows 10 (1903)
  • Compiler name and version number: Visual Studio 2019 (default compiler)
@koonyook koonyook added the type: bug Indicates an unexpected problem or unintended behavior label Jan 19, 2020
@ryo-y-murakami
Copy link

It works fine with /vd2 compiler option.

@donnyward
Copy link
Contributor

donnyward commented Dec 11, 2020

I have the same crash on createShapeNodeWith, last traceable line is where the dynamic_cast occurs. This is using the dart package from vcpkg with a tiny sample program building a skeleton with one joint and body.

Adding /vd2 to the project does not make a difference. Using VS2019

@traversaro
Copy link
Contributor

Related issue (I guess): #1522 .

@erwincoumans
Copy link
Contributor

Thanks to @ryo-y-murakami, I confirm that adding /vd2 in the root CMakeLists.txt makes the Windows build work, Visual Studio 2019.

@jslee02
Copy link
Member

jslee02 commented Apr 14, 2021

I believe this issue is fixed by #1541

@jslee02 jslee02 closed this as completed Apr 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

6 participants