-
Notifications
You must be signed in to change notification settings - Fork 289
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
dynamic_cast failures on MacOS: A consequence of Apple's Command Line Tools' update. #4014
Comments
Thanks for the detailed analysis, that sounds like it would have been very annoying to debug. I think I'd be in favor of dropping the |
Oh, what a travesty. We still have a I'm loathe to make our code uglier again because a three trillion dollar company can't be bothered to properly regression test one of their core products. And obviously from a users' perspective the right thing to do here is not "work around one bit of breakage but then cross our fingers and continue using the obviously-broken product", it's "downgrade until Apple finally notices and fixes their junk". I hate leaving users to learn about this little mess on their own in their own applications, though. That's IBAMR code breaking above, right? Do we not hit anything in libMesh Maybe there's something else reasonable we can do on our end? ... our current test for RTTI just tries to compile some typeid code and sees if that fails, but if we were to also check for runtime failures then we could disable RTTI in those cases too, and then any code that uses |
In theory it changes every self-call from a final class from "bounce off the vtable" to "direct function call, can even be inline". I'd hope compilers are taking advantage of that. I could be talked into going back to |
Hi @roystgnr, Yes, I only experienced this issue using IBAMR. When I ran When I have some spare time, I'd be happy to write short test mirroring the stackoverflow post I attached above to check for this compiler issue. Just let me know. |
I'll put up a PR shortly, but I'll beg you to test it before we merge; thanks! |
Hmm... actually, is this something we can work around on our side, by moving the virtual On top of the test I'll try a workaround on this theory; you could look at both the test before the workaround and the test afterward to see if we get lucky here. |
I gave up on the workaround (too many classes that could possibly be affected depending on how accurate my vague understanding of the problem is), but if you could give the unit test in #4015 a try I'd appreciate it. |
@roystgnr I tried out the unit tests implemented in #4015 and, surprisingly, they all pass. Perhaps the issue is specifically related to the "final" keyword. `./unit_tests-opt --re Casting OK (3 tests)` |
Okay, that's disturbing. There's nothing different here with regards to the
No rush, but I'm afraid I want to take you up on this now. |
Hi @roystgnr, sorry for the delay, but I was able to reproduce the error observed in the original stack overflow post. Here is another relevant github post which seems to be addressing the same issue: RobotLocomotion/drake#22204 |
Any chance you could come up with a unit test that reproduces it? I'm not sure why my attempt didn't. Have you tried that |
Hi @roystgnr, Sure! However, it would be helpful if you could provide me with some guidance regarding how unit tests are generally set up. I can't promise I'll be able to get to this right away, but I should be able to get to it in the next couple of days or so. I tried using the flag |
You need cppunit (either in a system path or in paths specified via |
Hi @roystgnr, thanks! I have cppunit and I already used it to the tests you asked me to try above. I was more curious about the workflow for writing a test and if there is anything more nuanced that I should be aware of. |
Oh, of course you did. Sorry; cppunit is probably our optional package with the highest ratio of "usefulness for developers" over "likelihood of already being installed" so I go into my "make sure you installed cppunit" spiel at the drop of a hat. The only other hassle likely to apply to you is that if your test doesn't "belong" in an existing group of tests then you'll need to modify The hassle that applies to most users writing new tests is that we run our tests in a zillion different configurations, and it's easy to write something that breaks if Number==Complex or PETSc is disabled or AMR is disabled or Mesh is a DistributedMesh on 11 processors or some such, but I don't think any of that is likely to hit you. |
Hello,
Just a heads up: after updating to MacOS command line tools 16.1, I encountered dynamic_cast failures in IBAMR (which uses libmesh to handle finite elements) when compiler optimizations are enabled. The issue occurs in the following function:
The assertion error appears to be caused by a compiler bug associated with how the updated compiler handles virtual tables for shared libraries (see: https://stackoverflow.com/questions/79192304/macos-xcode-16-breaks-dynamic-cast-for-final-types-defined-in-shared-library).
Following the stackoverflow post, I found that removing the
final
keyword from the PetscVector class declaration in libmesh/include/numerics/petsc_vector.h resolves the issue. I suppose this issue will crop up whenever an object from a class marked as 'final' is dynamically cast with optimizations turned on and so removing the final keyword could provide a workaround until this compiler bug is fixed.The text was updated successfully, but these errors were encountered: