[issue39277] _PyTime_FromDouble() fails to detect an integer overflow when converting a C double to a C int64_t

2022-02-07 Thread STINNER Victor
STINNER Victor added the comment: New changeset d3e53bc5321a9f08c7ed5b9383eefb2e03dfa6e2 by Victor Stinner in branch 'main': bpo-39277: Fix PY_TIMEOUT_MAX cast in _threadmodule.c (GH-31195) https://github.com/python/cpython/commit/d3e53bc5321a9f08c7ed5b9383eefb2e03dfa6e2 --

[issue39277] _PyTime_FromDouble() fails to detect an integer overflow when converting a C double to a C int64_t

2022-02-07 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +29365 pull_request: https://github.com/python/cpython/pull/31195 ___ Python tracker ___

[issue39277] _PyTime_FromDouble() fails to detect an integer overflow when converting a C double to a C int64_t

2020-06-25 Thread Stefan Krah
Stefan Krah added the comment: C99, 6.3.1.4 Real floating and integer: """ When a value of integer type is converted to a real floating type, if the value being converted can be represented exactly in the new type, it is unchanged. If the value being converted is in the range of values that

[issue39277] _PyTime_FromDouble() fails to detect an integer overflow when converting a C double to a C int64_t

2020-06-24 Thread Stefan Krah
Stefan Krah added the comment: Is it a bug in float.__trunc__()? It seems to me that the detailed comment accounts for case of rounding up. That's why < is used instead of <=. -- nosy: +skrah, tim.peters ___ Python tracker

[issue39277] _PyTime_FromDouble() fails to detect an integer overflow when converting a C double to a C int64_t

2020-03-12 Thread STINNER Victor
STINNER Victor added the comment: Oh, clang on FreeBSD spotted a similar bug in float.__trunc__()! static PyObject * float___trunc___impl(PyObject *self) /*[clinic end generated code: output=dd3e289dd4c6b538 input=591b9ba0d650fdff]*/ { double x = PyFloat_AsDouble(self); double

[issue39277] _PyTime_FromDouble() fails to detect an integer overflow when converting a C double to a C int64_t

2020-01-10 Thread STINNER Victor
STINNER Victor added the comment: Similar issue in HHVM: * https://github.com/facebook/hhvm/issues/5932 * https://github.com/PPC64/hhvm/commit/7cdb76b4f495aa7aa40a696379862916c27f5828 -- ___ Python tracker

[issue39277] _PyTime_FromDouble() fails to detect an integer overflow when converting a C double to a C int64_t

2020-01-10 Thread STINNER Victor
Change by STINNER Victor : -- keywords: +patch pull_requests: +17338 stage: -> patch review pull_request: https://github.com/python/cpython/pull/17933 ___ Python tracker ___

[issue39277] _PyTime_FromDouble() fails to detect an integer overflow when converting a C double to a C int64_t

2020-01-10 Thread STINNER Victor
STINNER Victor added the comment: _PyTime_FromDouble() checks if!(_Py_DoubleInIntegralTypeRange(_PyTime_t, d)) with the macro: #define _Py_InIntegralTypeRange(type, v) (_Py_IntegralTypeMin(type) <= v && v <= _Py_IntegralTypeMax(type)) and _Py_IntegralTypeMax(type)=2**63-1. "v <=

[issue39277] _PyTime_FromDouble() fails to detect an integer overflow when converting a C double to a C int64_t

2020-01-09 Thread Thomas Grainger
Change by Thomas Grainger : -- versions: -Python 2.7 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue39277] _PyTime_FromDouble() fails to detect an integer overflow when converting a C double to a C int64_t

2020-01-09 Thread STINNER Victor
STINNER Victor added the comment: It's a bug in _PyTime_FromDouble() which fails to detect the integer overflow when casting a C double to a C _PyTime_T (int64_t): bug in _Py_InIntegralTypeRange(_PyTime_t, d) where d is a C double. On my Fedora 31, double is a 64-bit IEEE 754 float,

[issue39277] _PyTime_FromDouble() fails to detect an integer overflow when converting a C double to a C int64_t

2020-01-09 Thread Thomas Grainger
New submission from Thomas Grainger : _PyTime_FromDouble() fails to detect an integer overflow when converting a C double to a C int64_t Python 3.7.5 (default, Nov 20 2019, 09:21:52) [GCC 9.2.1 20191008] on linux Type "help", "copyright", "credits" or "license" for more information. >>>