Large valid scheduled-trigger intervals cause signed 64-bit overflow
Self Checks
- I have read the Contributing Guide.
- This is only for bug report, if you would like to ask a question, please head to Discussions.
- I have searched for existing issues search for existing issues, including closed ones.
- I confirm that I am using English to submit this report, otherwise it will be closed.
- 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
- Please do not modify this template :) and fill in all the required fields.
OceanBase version
OceanBase CE 5.0.2.0, source revision d128661ca4f5b3d167c1928e556d70d2f901baef.
Self Hosted
Self Hosted (Source)
Environment
Ubuntu 22.04.5 LTS, x86_64. The component was compiled with GCC 9.5.0 and
-fsanitize=undefined -fno-sanitize-recover=undefined. The attached
poc.py needs Python 3, g++, and a checkout of the affected OceanBase source.
Steps to reproduce
Save the single attached file as
poc.py.Run it against the OceanBase checkout:
python3 poc.py /path/to/oceanbaseThe PoC first verifies that the source still accepts
interval_val <= INT32_MAXand contains the affected multiplication insrc/share/balance/ob_scheduled_trigger_partition_balance.cpp.It compiles the same accepted-domain arithmetic with UBSan and runs one safe control plus the two values used in the source-anchored reproduction.
Observed output is equivalent to:
control: value=100 freq=60 result=6000000000
daily trigger: runtime error: signed integer overflow: 17280000000000 * 1000000 cannot be represented in type 'long int'
weekly trigger: runtime error: signed integer overflow: 18144000000000 * 1000000 cannot be represented in type 'long int'
REPRODUCED: accepted interval domain overflows int64 arithmeticThe affected code parses the interval into int64_t, permits any positive
value up to INT32_MAX, selects SECS_PER_DAY or seven days, and then executes:
interval_ts = interval_val * freq_ts * USECS_PER_SEC;The authoritative exact-function run had two clean controls and two UBSan
failures. The result file SHA-256 is
570ecd1317f124c82031a125f3296076f4d91c9d47b149587e3b3bb4cdbe3b79.
✔️ Expected Behavior
The parser should either reject an interval whose microsecond value cannot fit
in int64_t, or perform checked multiplication and return a clear range error.
No accepted input should invoke signed-overflow undefined behavior.
❌ Actual Behavior
Large DAILY and WEEKLY interval values pass the explicit INT32_MAX validation
and then overflow the signed 64-bit multiplication. UBSan stops at the current
assignment. Without UBSan, the computed scheduling interval can wrap to an
unrelated value.
Source: oceanbase/oceanbase