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

[BUG] dynamic_cast fails on Mac because of missing visibility annotations #1974

Open
adalisk-emikhaylov opened this issue Nov 27, 2024 · 0 comments
Labels

Comments

@adalisk-emikhaylov
Copy link

Environment

Operating System: MacOS x64 12.7.6
Version / Commit SHA: VDB 12.0.0 (from brew)
Other: Apple clang version 13.1.6 (clang-1316.0.21.2.5)

Describe the bug

After loading a grid using openvdb::io::Stream::getGrids(), we're unable to dynamic_cast (it returns null) it to the type openvdb::FloatGrid, despite typeid(...).name() reporting the same name for both.

To Reproduce

Steps to reproduce the behavior:

  1. Build your code with -fvisibility=hidden on a Mac.
  2. Load a grid using openvdb::io::Stream::getGrids() then try to dynamic_cast it to openvdb::FloatGrid.
  3. Observe that the cast returns null, but at the same time typeid(openvdb::FloatGrid).name() and typeid(your_grid).name() return the same string.

Expected behavior

The dynamic_cast succeeds.

Additional context

This bug is caused by the missing __attribute__((__visibility__("default"))) annotation on your classes. Adding the annotation makes the cast pass.

I added annotations to the following classes:

openvdb::Grid
openvdb::tree::Tree
openvdb::tree::RootNode
openvdb::tree::InternalNode
openvdb::tree::LeafNode

This is the type that openvdb::FloatGrid expands to, plus all its template arguments. I haven't tested if marking all those classes is necessary, but IIRC even the template arguments need to be marked.

I'm not well-versed in openvdb, so I don't know if any other classes have the same issue or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant