Mitigation for pybind11 exceptions being forcibly exported
还没有人认领这个 Issue。
- #1418 来自 @feltech —— 已关闭,未合并
评估
调研方向
未指定文件或测试。首先评估所述的 PYBIND11_EXPORT_EXCEPTION 和 PYBIND11_NAMESPACE 选项,以及它们对跨越 OpenAssetIO Python 模块和宿主应用程序的异常的影响。完成的标准是已实现选定的缓解措施,并验证其跨版本的异常和 ABI 行为。
由索引模型根据 Issue 内容生成。
描述
What
Decide whether to mitigate and if so design and implement a mitigation for exception types defined by pybind11 being exported by the pybind11 library (i.e. default visibility).
Why
Ideally, all OpenAssetIO dependencies are private and do not leak to the host application (with the notable exception of Python itself). This includes pybind11, where it would be ideal if OpenAssetIO's Python bindings are independent from the host application, i.e. where the host could use a different version of pybind11 if they wished, and everything would still work.
However, it turns out that pybind11 exports it's exception classes. In particular, the pybind11::error_already_set exception type that is used to carry Python exception data through a C++ exception (and potentially back to Python again).
For example, the ABI of the error_already_set type was changed radically between pybind11 2.9 and 2.10. If OpenAssetIO is built with 2.10 and the host is built with 2.9, and the exception is caught in the host (even as a std::exception), and .what() is called on it, the wrong implementation of .what() might be executed, giving garbled text.
The only solution for now is for consumers to ensure OpenAssetIO is built with the same version of pybind11 as the host application.
Notes
One quick solution to this is to set -DPYBIND11_EXPORT_EXCEPTION="", but this may have other unwanted side-effects - e.g. if we needed to catch a pybind11-specific exception in openassetio-python.so (Python<->C++ bridge) that was thrown by _openassetio.so (Python extension module).
Another option is to change the pybind11 namespace. This isn't trivial to do. We can completely change pybind11 to something else (by setting PYBIND11_NAMESPACE), and update all our code usages. But ideally the pybind11 authors would add an inline namespace to protect against ABI changes, as we do.
- 主要语言
- C++
- 星标
- 352
- 派生
- 48
- 平均合并
- 4 天 14 小时
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
OpenAssetIO/OpenAssetIO 的其他 Issue
-
bug test
难度 2/5 1-3 小时 新手友好度 82/100
OpenAssetIO/OpenAssetIO#1527 ·
-
difficulty/medium help wanted
难度 5/5 一周以上 新手友好度 25/100
OpenAssetIO/OpenAssetIO#1504 · 2 条评论 ·
-
difficulty/hard help wanted
难度 4/5 3-5 天 新手友好度 42/100
OpenAssetIO/OpenAssetIO#1503 · 7 条评论 ·
-
difficulty/hard help wanted
难度 5/5 一周以上 新手友好度 30/100
OpenAssetIO/OpenAssetIO#1502 ·
-
difficulty/hard help wanted
难度 5/5 一周以上 新手友好度 30/100
OpenAssetIO/OpenAssetIO#1501 ·
查看 OpenAssetIO/OpenAssetIO 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
ROCm/rocm-systems#15475 ·
维护者通常 2 天内回复
-
难度 1/5 1 小时以内 新手友好度 68/100
Sendspin/sendspin-cpp#257 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
pocoproject/poco#5664 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100