sourcepawn icon indicating copy to clipboard operation
sourcepawn copied to clipboard

UB reported by -fsanitize=undefined and -fhardened

Open Hex4dec opened this issue 7 months ago • 1 comments

.../sourcemod/sourcepawn/compiler/lexer.cpp:1687:15: runtime error: signed integer overflow: 8 + 2147483640 cannot be represented in type 'int'
.../sourcemod/public/amtl/amtl/am-hashtable.h:619:25: runtime error: left shift of 139267842197648 by 18 places cannot be represented in type 'long int'
.../sourcemod/public/amtl/amtl/am-hashtable.h:623:22: runtime error: left shift of negative value -8088623492029875168
.../sourcemod/public/amtl/amtl/am-hashtable.h:623:9: runtime error: signed integer overflow: -8088623492029875168 + -1163069426044565504 cannot be represented in type 'long int'
.../sourcemod/public/amtl/amtl/am-hashtable.h:610:7: runtime error: signed integer overflow: 519 * 668265261 cannot be represented in type 'int'
.../sourcemod/sourcepawn/compiler/semantics.cpp:624:37: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
.../sourcemod/public/amtl/amtl/am-hashtable.h:621:9: runtime error: signed integer overflow: -1214057357710943445 * 21 cannot be represented in type 'long int'
.../sourcemod/public/amtl/amtl/am-hashtable.h:619:25: runtime error: left shift of 139267843814832 by 18 places cannot be represented in type 'long int'
.../sourcemod/public/amtl/amtl/am-hashtable.h:623:22: runtime error: left shift of negative value -8088649981491996740
.../sourcemod/public/amtl/amtl/am-hashtable.h:623:9: runtime error: signed integer overflow: -8088649981491996740 + -1164764751620346112 cannot be represented in type 'long int'
.../sourcemod/public/amtl/amtl/am-hashtable.h:619:25: runtime error: left shift of 138649366851436 by 18 places cannot be represented in type 'long int'
.../sourcemod/public/amtl/amtl/am-hashtable.h:621:9: runtime error: signed integer overflow: -547527180664437428 * 21 cannot be represented in type 'long int'
.../sourcemod/public/amtl/amtl/am-hashtable.h:623:22: runtime error: left shift of 6945298692562283313 by 6 places cannot be represented in type 'long int'

While the majority of errors appear to be in sourcemod, this happens only when using spcomp.

Hex4dec avatar Jun 16 '25 08:06 Hex4dec

You can safely ignore these errors, they're spurious. However you might be able to quell them by changing HashInt32/HashInt64 to take uint32_t/uint64_t.

dvander avatar Jun 16 '25 15:06 dvander