-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[BUG] Access violation under Windows in test_chrono_system_clock_roundtrip_time
#2601
Comments
MSVC specifies that it returns a nullptr
So this seems very similar to #2417? @dorozhkin-stc, two silly things:
@bstaletic, this might be that same bug from before, but in a slightly different form. Any suggestions? |
If we solve it before the release, and it looks safe to add, I think we can put in in 2.6.0. Otherwise, I don't think there's a problem making it target 2.6.1, I don't think it's a release blocker? (though we do claim to have fixed a rare time bug, and sadly now we know about another one...) |
According to the C standard,
So unfortunately for us, we can't blame MSVC. Instead, we should check for NULL and throw. The Linux man page says this:
But MSVC says that it might set |
Well, no, because: remember those time zone conversions, and pybind11 picking the 1st of January 1790 to convert a |
We can try hacking around it, by converting EDIT: Or 1971 - 1, to avoid leap years and leap seconds. And only if the year we get is 1970. And this still wouldn't work for 2040... We definitely should be checking for NULL. |
Indeed I am in GMT+3.
The issue had been originally triggered (and reported) when I tried to build the project around 21-22 PM in local time. |
@dorozhkin-stc Thanks!
I forgot: we added some tests in #2417 that don't just use the current time, so it shouldn't matter when you run it, indeed :-) |
Hello, I'm trying to compile pybind11 tests on visual studio and I encountered the same problem. |
Issue description
Test case
test_chrono_system_clock_roundtrip_time
from test_chrono.py fails with access violation (null pointer dereference) when passing instances ofdatetime.time
tom.test_chrono2()
pybind11/tests/test_chrono.py
Line 104 in 2e31e46
Steps to reproduce
Build the project and run unit tests.
Behaviour is observed with 2.6.0.rc2 under Windows (VS2017/VS2019 compilers and Python 3.7 and 3.8 have been tested).
Removing all variants of
datetime.time(..)
parameters https://github.com/pybind/pybind11/blob/2e31e466dc7591612b4b17300797d352e1f3f801/tests/test_chrono.py#L85..L91 makes all tests pass.The text was updated successfully, but these errors were encountered: