lua-users home
lua-l archive

Re: clang memory sanitizer report unsigned int overflow

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


In some context I may imagine an uint overflow could be a symptom of a bug even if it has a perfectly defined semantic in C. Maybe that tool can be configured to signal uint overflows even if they are perfectly defined in C?Just guessing.
-- Lorenzo
On 05/01/2023 15:05, Roberto Ierusalimschy wrote:
For reference that is this line marked with **:
 | unsigned int luaS_hash (const char *str, size_t l, unsigned int seed)
{
 | unsigned int h = seed ^ cast_uint(l);
 | for (; l > 0; l--)
**| h ^= ((h<<5) + (h>>2) + cast_byte(str[l - 1]));
 | return h;
 | }
Though not sure which part of that would be causing an add overflow because
h is an unsigned int which I believe should not trigger UB when it
overflows.
The 'reason' itself states "Unsigned integer overflow", which does not
exist in ISO C...
 Process 626150 stopped
 * thread #1, name = 'ufsrv', stop reason = Unsigned integer overflow
 ??????????????????????????????????
-- Roberto

AltStyle によって変換されたページ (->オリジナル) /