[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Incorrect optimization of function isinstack
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 22 Feb 2021 12:14:23 -0300
> To further emphasize your point: since subtracting unrelated pointers
> is Undefined Behavior, even on such a hypothetical architecture,
> compilers would still be allowed to perform this optimization. The
> comment that "the subsequent checks are ISO C and ensure a correct
> result" is wrong. If isinstack is ever called where o and base are
> unrelated, the entire execution is undefined.
You are right :-(
One option to fix that would be to traverse the whole segment looking
for a pointer equality: Slow but correct. The size would be the number
of registers in a Lua function. This is limited to 255, but usually is
much smaller.
-- Roberto