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

Segmentation fault - datetime python module #1171

Closed
SrGitQ opened this issue Jan 23, 2024 · 3 comments · Fixed by PyO3/pyo3#3818
Closed

Segmentation fault - datetime python module #1171

SrGitQ opened this issue Jan 23, 2024 · 3 comments · Fixed by PyO3/pyo3#3818
Assignees

Comments

@SrGitQ
Copy link

SrGitQ commented Jan 23, 2024

          @SrGitQ can you please open that as a new issue with a full repro of instructions how to observe this (including the source code)? I would be happy to investigate.

Originally posted by @davidhewitt in #451 (comment)

To recreate this Issue I will create a new virtual environment [python 3.12] in my Ubuntu OS (I tested this bug on my other computers with different OS). Then I created two python scripts main.py and datetime.py. In main.py I will import pydantic and try to run this script.
Here is the content of main.py

from pydantic import BaseModel

class AnyClass(BaseModel):
    ...

The python execution will be crashed by a segmenetation fault error (parent reference).

@davidhewitt
Copy link
Contributor

Thanks, what about the contents of datetime.py? What are the exact steps I should take to observe this crash?

@SrGitQ
Copy link
Author

SrGitQ commented Jan 23, 2024

Thanks, what about the contents of datetime.py? What are the exact steps I should take to observe this crash?

That's it...
datetime.py is empty. Even if it is a folder with a __init__.py file (which is considered a module) it crash...
You can observe some logs by enable the faulthandler but that's all you need to crash it.

@davidhewitt
Copy link
Contributor

Right, so I see what is going on, this looks like a PyO3 upstream bug. The cause is that the datetime standard library module is replaced by your empty datetime module, but PyO3 is handling this very badly...

Let's see if we can get this fixed 👍

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 a pull request may close this issue.

3 participants