[BUG]: Crashed when importing a python file in DLL
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
Hi everybody,
I'm using pybind11 in DLL to load a python file code but it crashed when calling the py::module::import(...) function, and it stopped at this line https://github.com/pybind/pybind11/blob/master/include/pybind11/detail/class.h#L68 in include/pybind11/detail/class.h

My codes run well in an EXE, but in DLL it crashed.
Currently, I really do not know why.
I googled and tried to fix this issue but did not succeed.
I also tested that run DLL in another thread and main thread of EXE but it crashed both 2 cases.
P.S I created this from Discussions so my bug report has no default bug format. Sorry.
Thanks,
Vic P.
Originally posted by @vic4key in https://github.com/pybind/pybind11/discussions/3267
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
Start at include/pybind11/detail/class.h:68 and the py::module::import(...) call, then reproduce the crash in the DLL and compare it with the working EXE case. Done means identifying the DLL-specific cause and documenting or validating a minimal reproduction and fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- backend, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100