[BUG]: trying to catch a py::type_error makes the compilation crash with Clang on Windows
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
Problem description
The compiler Clang v13.0.0 craches at the linking step on Windows when add to following line to my code :
try {
auto casted_values = py::cast<std::vector<int32_t>>(values); // Here values is a py::list&.
} catch (const py::cast_error& e) {
throw py::type_error("this method expects integers as param");
}
The error is :
LLVM ERROR: Associative COMDAT symbol '??0builtin_exception@pybind11@@QEAA@PEBD@Z' does not exist.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
The strange thing is that if I recompile the same code but keep the CMake cache, it works. 🤔
It also works perfectly under Linux with CGG.
Does anyone have an explanation for this?
EDIT : It seems that the problem comes from the try catch but I have no idea why.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the sample try/catch with Clang 13.0.0 on Windows and inspect the linker error for builtin_exception. Compare a clean CMake configuration with a rebuild that keeps the CMake cache, then determine whether the py::cast_error handling consistently triggers the crash and document the cause or a verified workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100