Skip to content

faulthandler: use _PyTime_t rather than double for timeout#4139

Merged
vstinner merged 2 commits into
python:masterfrom
vstinner:faulthandler_pytime
Oct 27, 2017
Merged

faulthandler: use _PyTime_t rather than double for timeout#4139
vstinner merged 2 commits into
python:masterfrom
vstinner:faulthandler_pytime

Conversation

@vstinner
Copy link
Copy Markdown
Member

@vstinner vstinner commented Oct 26, 2017

Use the _PyTime_t type rather than double for the faulthandler
timeout in dump_traceback_later().

This change should fix the following Coverity warning:

CID 1420311: Incorrect expression (UNINTENDED_INTEGER_DIVISION)
Dividing integer expressions "9223372036854775807LL" and "1000LL",
and then converting the integer quotient to type "double". Any
remainder, or fractional part of the quotient, is ignored.

if ((timeout * 1e6) >= (double) PY_TIMEOUT_MAX) {

The warning comes from (double)PY_TIMEOUT_MAX with:

#define PY_TIMEOUT_MAX (PY_LLONG_MAX / 1000)

Use the _PyTime_t type rather than double for the faulthandler
timeout in dump_traceback_later().

This change should fix the following Coverity warning:

CID 1420311:  Incorrect expression  (UNINTENDED_INTEGER_DIVISION)
Dividing integer expressions "9223372036854775807LL" and "1000LL",
and then converting the integer quotient to type "double". Any
remainder, or fractional part of the quotient, is ignored.

    if ((timeout * 1e6) >= (double) PY_TIMEOUT_MAX) {

The warning comes from (double)PY_TIMEOUT_MAX with:

    #define PY_TIMEOUT_MAX (PY_LLONG_MAX / 1000)
format_timeout() is limited to LONG_MAX seconds, not to LONG_MAX
microseconds.
@vstinner vstinner merged commit 93fd478 into python:master Oct 27, 2017
@vstinner vstinner deleted the faulthandler_pytime branch October 27, 2017 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants