• Subject: Re: Assertion `(((((uv)->v.p != &(uv)->u.value))` fail
• From: Ziyao <ziyao@...>
• Date: Mon, 06 Feb 2023 23:57:00 +0800

```On 2023-02-06 20:36, Mouse wrote:
```
```Maybe I'm off base here, but I would expect a failure - but I would
expect it to be a well-controlled divide-by-zero failure, such as the
post says happens "[w]ithout assertion on".  The assertion failure, on
the other hand, I would call a bug.
```
```
You are right, but this failure seems not only to be caused by modulo
by 0.

There is a simpler version which triggers the failure:

for i = 0,0
do
local function f()
return i;
end
print(f() % 0);
end

The failure may have something to do with the loop's control variable
(if we remove the loop and redefine i as a local variable, it does not
occur) which is used as an upvalue.

In fact, the result of f() need not using directly, line 6 could
also be "print(f(), 0 % 0);", which triggers the failure as well.
In another word, the modulo MAY be only used to trigger an error,
which occurs after the f() is invoked ("print(0 % 0,f())" gives out
a proper message)

I say "MAY" here because "print(f(), error())" does NOT trigger
the assertion failure :(

Another interesting fact is that if LUAI_ASSERT is enabled, luac also
fails on an assertion.

\$ ./luac -l t.lua

main <t.lua:0,0> (16 instructions at 0x564f3267ccc0)
0+ params, 8 slots, 1 upvalue, 5 locals, 2 constants, 1 function
```
luac: luac.c:347: PrintCode: Assertion `((((enum OpMode)(luaP_opmodes[(((OpCode)(((i)>>0) & ((~((~(Instruction)0)<<(7)))<<(0)))))] & 7))) == iAx)' failed.
```Aborted

I am working on the release version of Lua 5.4.4. Hope this useful.

--
Ziyao

```

• References: