-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
Milestone
Description
Describe the bug
UBSan (undefined behavior sanitizer) reports integer overflow errors in Foundation/include/Poco/Dynamic/VarHolder.h during CI test runs.
Errors reported
From Linux CI (run 20053237550):
testLimitsInt: /home/runner/work/poco/poco/Foundation/include/Poco/Dynamic/VarHolder.h:477:34: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
/home/runner/work/poco/poco/Foundation/include/Poco/Dynamic/VarHolder.h:477:34: runtime error: negation of -9223372036854775808 cannot be represented in type 'long int'; cast to an unsigned type to negate this value to itself
From macOS CI (same run):
testLimitsInt: /Users/runner/work/poco/poco/Foundation/include/Poco/Dynamic/VarHolder.h:559:4: runtime error: -1280 is outside the range of representable values of type 'signed char'
/Users/runner/work/poco/poco/Foundation/include/Poco/Dynamic/VarHolder.h:547:4: runtime error: 1270 is outside the range of representable values of type 'signed char'
/Users/runner/work/poco/poco/Foundation/include/Poco/Dynamic/VarHolder.h:559:4: runtime error: -327680 is outside the range of representable values of type 'short'
/Users/runner/work/poco/poco/Foundation/include/Poco/Dynamic/VarHolder.h:547:4: runtime error: 327670 is outside the range of representable values of type 'short'
/Users/runner/work/poco/poco/Foundation/include/Poco/Dynamic/VarHolder.h:559:4: runtime error: -2.14748e+10 is outside the range of representable values of type 'int'
/Users/runner/work/poco/poco/Foundation/include/Poco/Dynamic/VarHolder.h:547:4: runtime error: 2.14748e+10 is outside the range of representable values of type 'int'
/Users/runner/work/poco/poco/Foundation/include/Poco/Dynamic/VarHolder.h:477:25: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
/Users/runner/work/poco/poco/Foundation/include/Poco/Dynamic/VarHolder.h:477:25: runtime error: negation of -9223372036854775808 cannot be represented in type 'long long'; cast to an unsigned type to negate this value to itself
/Users/runner/work/poco/poco/Foundation/include/Poco/Dynamic/VarHolder.h:547:4: runtime error: 2550 is outside the range of representable values of type 'unsigned char'
/Users/runner/work/poco/poco/Foundation/include/Poco/Dynamic/VarHolder.h:547:4: runtime error: 655350 is outside the range of representable values of type 'unsigned short'
/Users/runner/work/poco/poco/Foundation/include/Poco/Dynamic/VarHolder.h:547:4: runtime error: 4.29497e+10 is outside the range of representable values of type 'unsigned int'
Root cause
The issues are in:
- Line 477: Negation of minimum integer values (e.g.,
-INT_MINis undefined behavior) - Lines 547/559: Type conversions that overflow the target type's range
Expected behavior
UBSan should report no errors. The code should properly handle edge cases for integer limits.
Environment
- OS: Ubuntu 24.04, macOS latest
- POCO Version: main branch (as of 2025-12-09)
- CI runs:
linux-gcc-cmake-ubsan,macos-clang-cmake-openssl3-ubsan
Related
Found while investigating #4908 (which reported different UBSan errors that are now handled).
Reactions are currently unavailable