Possible issue with constructor limits

156 views
Skip to first unread message

Sainan

unread,
May 24, 2025, 7:42:49 AMMay 24
to lu...@googlegroups.com
I just saw commit 267ef461d0b13aa28d667f12d1a61452c9db529c ("Bug: check for constructor overflow in [exp] fields") and it made me think about how in theory this 'limit' is never hit at all because if we expand checklimit it's basically:

if (cc->nh > MAX_INT) errorlimit(...);

All types here are signed ints, and I do not think any instance of int > MAX_INT is ever true.

-- Sainan

Roberto Ierusalimschy

unread,
May 26, 2025, 2:58:33 PMMay 26
to 'Sainan' via lua-l
> I just saw commit 267ef461d0b13aa28d667f12d1a61452c9db529c ("Bug: check for constructor overflow in [exp] fields") and it made me think about how in theory this 'limit' is never hit at all because if we expand checklimit it's basically:
>
> if (cc->nh > MAX_INT) errorlimit(...);
>
> All types here are signed ints, and I do not think any instance of int > MAX_INT is ever true.

Indeed.

-- Roberto

Roberto Ierusalimschy

unread,
May 27, 2025, 10:16:30 AMMay 27
to 'Sainan' via lua-l
This check is actually superfluous: Each field must generate at least
one opcode, and the number of opcodes is already limited by MAX_INT.
The same reasoning applies to 'na', the count of list fields; this
one never had an explicit check.

-- Roberto
Reply all
Reply to author
Forward
0 new messages