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

Define (non-empty) PYBIND11_EXPORT_EXCEPTION only under macOS. #4298

Merged
merged 1 commit into from
Oct 31, 2022

Conversation

rwgk
Copy link
Collaborator

@rwgk rwgk commented Oct 31, 2022

Description

Background: #2999, #4105, #4283, #4284

In a nutshell:

Suggested changelog entry:

`PYBIND11_EXPORT_EXCEPTION` was made non-empty only under macOS. This makes Linux builds safer, and enables the removal of warning suppression pragmas for Windows.

Background: pybind#2999, pybind#4105, pybind#4283, pybind#4284

In a nutshell:

* Only macOS actually needs `PYBIND11_EXPORT_EXCEPTION` (pybind#4284).

* Evidently (pybind#4283), under macOS `PYBIND11_EXPORT_EXCEPTION` does not run the risk of introducing ODR violations,

* but evidently (pybind#4283) under Linux it does, in the presumably rare/unusual situation that `RTLD_GLOBAL` is used.

* Windows does no have the equivalent of `RTLD_GLOBAL`, therefore `PYBIND11_EXPORT_EXCEPTION` has no practical benefit, on the contrary, noisy warning suppression pragmas are needed, therefore it is best left empty.
@rwgk rwgk marked this pull request as ready for review October 31, 2022 09:18
@rwgk
Copy link
Collaborator Author

rwgk commented Oct 31, 2022

I think this would be good to have in 2.10.1, too. Nobody complained about ODR violations, or the need to deal with the Windows warnings, but this gets rid of both stumbling stones. We may just be saving a handful of people a few hours of unhappiness.

@rwgk
Copy link
Collaborator Author

rwgk commented Oct 31, 2022

@oraluben JIC you want to look or comment.

@oraluben
Copy link
Contributor

  • ...therefore PYBIND11_EXPORT_EXCEPTION has no practical benefit, on the contrary, noisy warning suppression pragmas are needed, therefore it is best left empty.

LGTM

@henryiii
Copy link
Collaborator

I'm a little worried about changes like this hours or minutes before a release, but it looks pretty safe. If we do wait, we can put it in immediately after release. I'll leave it up to @Skylion007.

@Skylion007
Copy link
Collaborator

Skylion007 commented Oct 31, 2022

under Linux it does, in the presumably rare/unusual situation that RTLD_GLOBAL is used.

We have used that quite frequently to work around issues with Magnum / Habitat-Sim bindings playing nicely together... To clarify, are you saying this PR would cause issues there? Or fix a potential regression and therefore issues? I don't think we worry that much about pybind11 exceptions propogating between the two though.

@rwgk
Copy link
Collaborator Author

rwgk commented Oct 31, 2022

under Linux it does, in the presumably rare/unusual situation that RTLD_GLOBAL is used.

We have used that quite frequently to work around issues with Magnum / Habitat-Sim bindings playing nicely together...

Oh!

To clarify, are you saying this PR would cause issues there? Or fix a potential regression and therefore issues? I don't think we worry that much about pybind11 exceptions propogating between the two though.

Did you also mix extensions built with different pybind11 versions? In that case I'd expect pretty terrible undefined behavior caused by the ODR violation for error_already_set, similar to what you see in the failures under #4283.

Now thinking: We really need to have this in 2.10.1.

In case you used pybind11 from sources, but a mix of source versions between extension: you're really on thin ice with RTLD_GLOBAL ever since #2999 was merged. "thin ice" == maybe ODR violation but maybe not.

In case you only used releases: mixing any two release that have #2999 is still on thin ice (I don't have time to look up the release history right now).

But especially after #1895 was merged, it's not just thin ice, ODR violations are a certainty, on Linux, withRTLD_GLOBAL, mixing pre-1895 with post-1895.

@henryiii henryiii merged commit b1bd7f2 into pybind:master Oct 31, 2022
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Oct 31, 2022
@rwgk rwgk deleted the export_exception_macos_only branch October 31, 2022 17:40
@henryiii henryiii removed the needs changelog Possibly needs a changelog entry label Oct 31, 2022
rwgk pushed a commit that referenced this pull request Nov 18, 2022
…#4298)

Background: #2999, #4105, #4283, #4284

In a nutshell:

* Only macOS actually needs `PYBIND11_EXPORT_EXCEPTION` (#4284).

* Evidently (#4283), under macOS `PYBIND11_EXPORT_EXCEPTION` does not run the risk of introducing ODR violations,

* but evidently (#4283) under Linux it does, in the presumably rare/unusual situation that `RTLD_GLOBAL` is used.

* Windows does no have the equivalent of `RTLD_GLOBAL`, therefore `PYBIND11_EXPORT_EXCEPTION` has no practical benefit, on the contrary, noisy warning suppression pragmas are needed, therefore it is best left empty.
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.

4 participants