[asterisk-bugs] [JIRA] (ASTERISK-22081) Type cast causes incorrect schedule interval

Roman S. (JIRA) noreply at issues.asterisk.org
Tue Jul 16 02:10:03 CDT 2013


Roman S. created ASTERISK-22081:
-----------------------------------

             Summary: Type cast causes incorrect schedule interval
                 Key: ASTERISK-22081
                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-22081
             Project: Asterisk
          Issue Type: Bug
      Security Level: None
          Components: General
    Affects Versions: 11.5.0, 10.12.2, 1.8.23.0
         Environment: linux 32 and 64
            Reporter: Roman S.
            Severity: Trivial


If there is a single event with {{when}} in the distant future then function {{ast_sched_wait}} returns zero value (no wait - run it now). This causes high CPU utilization.

This happens when {{ast_tvdiff_ms}} returns value of type {{int64_t}} which is greater then INT_MAX ({{ms}} of type {{int}}) - negative {{int}} value occurs).

{noformat}
int ast_sched_wait(struct ast_sched_context *con)
{
        int ms;
...
                ms = ast_tvdiff_ms(s->when, ast_tvnow());
{noformat}

{noformat}
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start),
{noformat}

For 32bit OS it's 24 days schedule interval - big enough, but still possible.

I suppose that type change and additional check is required:
{noformat}
        int64_t ms;
...
                if (ms > INT_MAX) {
                        ms = -1;
                else if (ms < 0) {
...
{noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.asterisk.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the asterisk-bugs mailing list