-
Notifications
You must be signed in to change notification settings - Fork 629
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
Fix libc++abi.dylib: Pure virtual function called! #685
Conversation
|
Strange, this should be (mostly) defined behavior, in that if you have class A with a virtual function foo, and class B derived from A which overrides that, you should be able to call foo from B's constructor and have that treated as if it is a B and call that (B::foo). Which in this particular scenario should be correct. That being said, it is ... dangerous ... in that if you then have a class C which is a subclass of B, and also overrides foo, then the call to foo in B's constructor will still only ever call B's version of the function. I wonder if the reason Apple clang fails to call B::foo on that is due to something to do with the final keyword implementation (which we don't have in this situation), such that it doesn't know it's the last virtual function, so it ends up in the wrong call. Either way, thanks for digging into this. |
@kdt3rd well the standard is pretty clear about that: https://stackoverflow.com/questions/962132/calling-virtual-functions-inside-constructors |
I verified that MSVC as well can fail in the same way with a small test program. |
Thanks for the fix here. Could we kindly ask you to add a signoff to the commit? The DCO check failed above because the commit is missing the "Signed-off-by" signature. The instructions are on the "Detail" link above, https://github.com/AcademySoftwareFoundation/openexr/pull/685/checks?check_run_id=497475513. Thanks. |
Signed-off-by: Phyrexian <[email protected]> Signed-off-by: Dorian Gomez <[email protected]>
On MacOS, we may end up with the following runtime error. OpenEXR/dwaLookups.h libc++abi.dylib: Pure virtual function called! Fix dwaLookup generation which is due to calling the base function from constructor which calls the overriden method run, which causes the base class to call the pure virtual method only, which does not do anything. outfile ended up not being generated. Signed-off-by: Dorian Gomez <[email protected]>
@dgmzc, I'd like to merge this, but can you first add a line to the commit that reads: Signed-off-by: If you run "git commit -s", it will add the signoff automatically. Thanks. |
Oops, my apologies, it's already there. Merging now. |
On MacOS, we may end up with the following runtime error.
OpenEXR/dwaLookups.h
libc++abi.dylib: Pure virtual function called!
Fix dwaLookup generation which is due to calling the base function from constructor which calls the pure virtual method only, which does not do anything. output file ended up not being generated.
see similar Stackoverflow issue: https://stackoverflow.com/questions/14549489/how-to-fix-pure-virtual-function-called-runtime-error