Page MenuHomePhabricator

Fix transient divide by zero bug in 32-bit code

Authored by jlpeyton on Dec 4 2018, 3:37 PM.



The value returned by __kmp_now_nsec() can overflow 32-bit values causing incorrect values to be returned. The overflow can end up causing a divide by zero error because in __kmp_initialize_system_tick(), the value (__kmp_now_nsec() - nsec) can end up being much larger than the numerator:
1e6 * (delay + (now - goal))
during a pathological timing where the current time calculated is much larger than nsec. When this happens, the value of __kmp_ticks_per_msec is set to zero which is then used as the denominator in the KMP_NOW_MSEC() macro leading to the divide by zero error.

Diff Detail


Event Timeline

jlpeyton created this revision.Dec 4 2018, 3:37 PM
This revision is now accepted and ready to land.Dec 5 2018, 9:27 AM
This revision was automatically updated to reflect the committed changes.