lua-users home
lua-l archive

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


Hi,

> The line 6 is actually equal to f(0 % 0)
Yeah, but without the for-loop it will not trigger an assertion failure. I agree this code should trigger errors, but not an assertion failure.

> Are you still in this "Lua code testing machine" or for what
application are you using such strange command like 0% f(0)?

I am still doing fuzz testing. So the generated code might be "strange" (although often syntactically correct).

>why should #_ENV resolve to anything but 0 in this code?
The following poc also tiggers the same assertion failure:
---
for i = 0, 0 do
    local function f(...)
        _ENV[i], a = 0
        return 0
    end
    print(0 % f(0))
end
---

This is the smallest poc I can get.

Best,
Yongheng

On Mon, Feb 6, 2023 at 2:14 AM Bas Groothedde <lua@xoru.net> wrote:

On 05-02-2023 17:43, Yongheng Chen wrote:

---
for i = 0, 0 do
    local function f(...)
        _ENV[i], a = 0
        return #_ENV
    end
    f((0 % f((0))))
end
---
 
 
--
Best Wishes,
Yongheng Chen

Hi,

I'm missing something, why should #_ENV resolve to anything but 0 in this code?
As I'm reading the code, I expect there to be a '0 % 0', which is a division by zero.

Cheers,

~b



--
Best Wishes,
Yongheng Chen