-
Notifications
You must be signed in to change notification settings - Fork 287
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
SkelParser::readSkeleton assertion failure #412
Comments
It doesn't assume the .skel file has multiple joints, but it is, however, exhibiting undefined behavior, because it calls I'm about to submit a pull request that checks whether order.begin() is equal to order.end() before using it. |
Hopefully the assertion failure is fixed in pull request #415. If you get the chance, try it out and let me know if it's helped. If the problem was the undefined behavior that I noticed, then I won't have a way of checking for myself if the issue is resolved. |
this seems to address the issue, although i can't be sure (getting many other issues in skelparser). |
Are the other issues related to the Eigen alignment problems, or are they specific to the parser? |
there are many alignment things that i think i have addressed, but i also had to add a copy constructor for MultiDofJoint::UniqueProperties, since one is called in the init list for a free joint and i am currently attempting to address the upcast of properties to uniqueproperties in dynamics::detail::multidofjoint.h - an assertion is failing in MultiDofJoint::setDampingCoefficient since d (the coefficient value) doesn't appear to be initialized, and so is some negative garbage value. |
I find this surprising, since all the contents of MultiDofJoint::UniqueProperties should be entirely copy-safe. Could this be an alignment issue? What if you added |
nope. i get a bad_alloc on the freejoint multi-dof constructor. |
Has |
We would want |
Is this still happening in eigen_aligned_allocator branch? |
I've added those directives in all those places. (need to have one in Inertia.h, btw, too). The data in the properties structure is definitely garbage - i'm stepping through it, and the assertion in setDampingCoefficient is firing because d is ~ -9e-308. stepthrough :
2)line 398 skelParser.cpp until i can fix this i won't be able to tell if all the alignment issues are addressed. (i will temporarily remove the assertion) |
this should probably move to another issue. |
Yeah, that's clearly an uninitialized garbage number. Did you say that creating a user-defined copy constructor helped with this damping coefficient issue? We could migrate this to another issue I suppose. |
i'm sorry, i had something of a run on there and was unclear. the garbage data causing the assertion is later in the execution path - in the body of the freejoint ctor. |
Wow, so the default copy constructor was resulting in a bad_alloc exception? That's even more insane than what I was interpreting. Are you able to monitor the memory on your system as it runs? Could there be some huge memory leak going on? I don't know what causes bad_alloc except for running out of memory. |
According to this thread, bad_alloc can occur from a race condition. You mentioned that you were running multithreaded applications, right? Could that have anything to do with what's going on? |
there are no threads instantiated yet, this is from main. my multithreaded code is in a particular section much further down the execution path. could this be the issue : |
as i recall that struct has a destructor - could the "deprecated" == "removed in some compilers, not in others"? |
At worst, the deprecation means it is a discouraged feature which will be removed in a later standard (probably C++17). That is a good thing to know about, though; I wasn't aware of that change. The reason for the destructors being defined is to allow inheritance to work properly by making their destructors virtual. We don't do anything special in the destructors, so we're not violating The Rule of 3 / The Rule of 5. In the future we can declare this for each struct:
But for right now, I'm fairly confident that this is not the issue. When you created the copy constructor for UniqueProperties, how did you define it? Did you just do a memberwise |
yep, pretty much. in multidofjoint.h, the copy ctor declaration :
|
This is really bizarre, because the implicit copy constructor should be doing this same exact thing. I'm starting to wonder if the bad_alloc is due to some insane compiler error in Visual Studio. |
i do recognize that i don't copy mDofNames, nor do i initialize either array's sizes. could this be an issue? |
Ah, good point: Your constructor should actually be resulting in undefined behavior, because mPreserveDofNames was not given a size before you start to set its entries. You should actually be able to include mDofNames and mPreserveDofNames in the initialization list, because std::vector has a perfectly reasonable copy constructor. The fact that this copy constructor is circumventing a problem that was created by the implicit copy constructor is completely mind-boggling to me. |
I actually copied the regular constructor - it too lacks both arrays getting initialized (so default initializer) and the mDofNames is not given any initial values. i changed the constructor to this :
and i now get a bad_alloc again heh. |
oh, btw those two are actually std::array, not vectors. so that's why the initialization wasn't failing before. |
Ding ding ding. I forgot that little tidbit, and I think it might explain everything. I vaguely remember reading that VS2013 does not fully support std::array yet. I'll look around to see if that's still true. In the meantime, creating a user-defined copy constructor and setting each of the components of the arrays in a for-loop. |
getting a bad_alloc in the copy ctor now - apparently the mdofnames array is never initialized, despite that i added an initializer in the ctor. the values in _o.mDofNames are : |
this looks like it also is the result of an upcast from a "properties" (weirdly enough a dart::planarjoint::properties, even though this is being called from the freejoint code in skelparser.cpp) |
So you're saying that the std::strings in mDofNames are not being initialized to empty strings by the default constructor for MultiDofJoint::UniqueProperties? I didn't realize VS2013 support for arrays was that bad. In the default constructor for MultiDofJoint::UniqueProperties, you could try changing
to
That should ensure that they get initialized. Then you'll want to make sure that the user-defined copy constructor has something similar.
I'm not really clear on what you mean here. If a PlanarJoint::Properties is being handled somewhere that a FreeJoint::Properties is expected, then that sounds like a bug to me. PlanarJoint and FreeJoint have a different number of DOFs, so their MultiDofJoint base classes are incompatible. |
apologies, the planar joint thing was a bug from me redoing the make_shared to the alloc_shared. copypasta error. on that note, in skelparser.cpp, line 527 i replaced the make_shared to allocate_shared as so :
to
and my question is should the allocator be a Joint::Properties or a FreeJoint::Properties ? thanks, and sorry again, that was weird. |
I would think you want Alternatively, I think you could merge in #414 and use Eigen::make_aligned_shared. It looks to me like that should work directly. |
ah, and that's it. by replacing all the make_shared calls, putting the alignment macros in, putting in the initialization and the copy ctor, and putting the allocators in for the stl containers, it fixed everything (skel reads in). obviously the bug i introduced (planar instead of free) was the source of the weird properties nonsense we've been discussing the last few posts. thanks for helping. |
Phew. Thanks for doing all the testing on this. I should really try to set up my Windows machine to run DART, but I can never decipher the linking issues I run into with Visual Studio. So in summary: VS2013 has a half-baked implementation of std::array, and we cannot rely on all compilers to support C++11 alignment. |
my pleasure, and yeah, that gives a pretty good rough summary heh. so, to recap, what i did (other than the check for order being empty) :
and that's about it. if i think of anything else that I had to do i'll edit this post, but i'm pretty sure that's it. |
I think the branch of Pull Request #414 should now work for you. Whenever you get a chance, try it out and let me know if it's working. |
thanks, i should be able to get to it later today, and i'll update you with what i find. |
sorry took so long to get back to you. other than the GL_MULTISAMPLE support, your fix + #414 appear to have fixed the problems discussed in this issue as well as the other skelparser issue, so i will close them. |
At line 544 :
it = joints.find(order.begin()->second);
after the first joint is processed this line fails due to order being empty.
The skeleton file i am using is based on (and nearly identical to, except for also having markers) fullbody1.skel, and the joint assigned to index just above is ("ground",0).
Edit : note this skeleton file has multiple skeletons (ground and biped), and the first one only has 1 joint defined. the code in this section looks like it may be predicated on the assumption that more than 1 joint will always exist in any skeleton.
The text was updated successfully, but these errors were encountered: