You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pytime.c:184 and pytime.c:218: runtime error, outside the range of representable values of type 'long' #65140
bpo-31373: demoting floating float values to unrepresentable types is undefined behavior
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2018-05-22.13:33:25.714>created_at=<Date2014-03-15.21:48:45.694>labels= ['tests']
title="pytime.c:184 and pytime.c:218: runtime error, outside the range of representable values of type 'long'"updated_at=<Date2018-05-22.13:33:25.713>user='https://bugs.python.org/JeffreyWalton'
>>> import _testcapi
>>> _testcapi.pytime_object_to_time_t(-1e+200, 0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: timestamp out of range for platform time_t
Signed integer overflow is undefined behaviour, so by the time *sec = (time_t)intpart has been evaluated, the undefined behaviour has already happened. It is too late to check for it afterwards.
Activity
JeffreyWalton commentedon Mar 15, 2014
pytime.c:184: runtime error: value -1e+200 is outside the range of representable values of type 'long'
and
pytime.c:218: runtime error: value -1e+200 is outside the range of representable values of type 'long'
It appears the cast on 'intpart' is generating the finding. 'intpart' is a double.
Shouldn't a range test based on TIME_T_MAX with an epsilon occur first?
vstinner commentedon Mar 16, 2014
Hi,
How did you get this warning?
Two lines after, the integer overflow is checked:
And it works, example:
(where 0 means _PyTime_ROUND_DOWN)
gareth-rees commentedon Mar 16, 2014
This looks like runtime output from a program built using Clang/LLVM with -fsanitize=undefined. See here: http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation
Signed integer overflow is undefined behaviour, so by the time *sec = (time_t)intpart has been evaluated, the undefined behaviour has already happened. It is too late to check for it afterwards.
vstinner commentedon Mar 17, 2014
What is this constant? I don't see it in Python source code.
vadmium commentedon May 19, 2018
Maybe worth checking if this is fixed due to the changes in bpo-31373 for 3.6+.
vstinner commentedon May 19, 2018
"resolution: out of date"
Is this issue fixed or not? It's still open.
vadmium commentedon May 19, 2018
I don’t know; I haven’t tested it. I was anticipating that it is fixed, but perhaps I should leave the resolution alone instead?
vstinner commentedon May 22, 2018
I close the issue as a duplicate of bpo-31373. Reopen/comment bpo-31373 if the issue is not completely fixed.