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

Use std::type_info::name() for type lookups outside stdlibc++ #915

Merged
merged 1 commit into from
Jun 24, 2017

Conversation

jagerman
Copy link
Member

@jagerman jagerman commented Jun 21, 2017

Using std::type_info::operator== fails under libc++ because the .so
is loaded with RTLD_LOCAL. libc++ considers types under such .sos
distinct, and so comparing typeid() values directly isn't going to work.

This adds a custom hasher and equality class for the type lookup maps
when not under stdlibc++, and adds a detail::same_type function to
perform the equality test. It also converts a few pointer arguments to
const lvalue references, particularly since doing the pointer
comparison wasn't technically valid to begin with (though in practice,
appeared to work everywhere).

This fixes #912, and closes #914 (it supersedes that one).

Using `std::type_info::operator==` fails under libc++ because the .so
is loaded with RTLD_LOCAL.  libc++ considers types under such .sos
distinct, and so comparing typeid() values directly isn't going to work.

This adds a custom hasher and equality class for the type lookup maps
when not under stdlibc++, and adds a `detail::same_type` function to
perform the equality test.  It also converts a few pointer arguments to
const lvalue references, particularly since doing the pointer
comparison wasn't technically valid to being with (though in practice,
appeared to work everywhere).

This fixes pybind#912.
@jagerman
Copy link
Member Author

(I kept this separate from #914 because it we don't want to merge this, we should at least merge the #914 changes).

@wjakob
Copy link
Member

wjakob commented Jun 22, 2017

You beat me to it! :) -- This looks great. The PR resolves all typeid issues on my Linux/x86_64 box.

@wjakob
Copy link
Member

wjakob commented Jun 24, 2017

Any objections to merging this? @dean0x7d?

@dean0x7d
Copy link
Member

No objections from me. Looks good!

@jagerman jagerman merged commit 2196696 into pybind:master Jun 24, 2017
@dean0x7d dean0x7d modified the milestone: v2.2 Aug 13, 2017
@jagerman jagerman deleted the typeid-name branch August 14, 2017 20:27
@rwgk rwgk mentioned this pull request Feb 9, 2023
barche added a commit to JuliaInterop/libcxxwrap-julia that referenced this pull request Jun 7, 2024
Fixes an error where different hashes were obtained in different libraries, see also:
pybind/pybind11#915
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typeid information not synchronized across shared library boundaries
3 participants