rce-incorporated / Fiu

Luau bytecode interpreter for Luau
MIT License
91 stars 18 forks source link

attempt to perform arithmetic (add) on nil and number #34

Closed capthehacker99 closed 4 months ago

capthehacker99 commented 7 months ago

I got the following error when using the bytecode below:

fiu.lua:459: attempt to perform arithmetic (add) on nil and number
stacktrace:
fiu.lua:459 function readProto
fiu.lua:506 function luau_deserialize
fiu.lua:533 function luau_load
fiu.lua:1281

bytecode.tar.gz

SnorlaxAssist commented 6 months ago

Can you provide how you produced this?

capthehacker99 commented 6 months ago

Luau version: git commit 9649e5e446e02e5383c11e16b300ab4b426242a1 Compile options:

Luau::Allocator allocator;
Luau::AstNameTable names(allocator);
Luau::ParseResult result = Luau::Parser::parse(string, size, names, allocator);

std::string error_combined;
if (!result.errors.empty())
    throw Luau::ParseErrors(result.errors);
Luau::CompileOptions copts;
copts.optimizationLevel = 2;
copts.debugLevel = 1;

copts.vectorLib = nullptr;
copts.vectorCtor = nullptr;
copts.vectorType = nullptr;
Luau::BytecodeBuilder bcb;
Luau::compileOrThrow(bcb, result, names, copts);
const auto& bytecode = bcb.getBytecode();
capthehacker99 commented 6 months ago

Source isn't available, but this can be reproduced with most large scripts.

capthehacker99 commented 6 months ago

Changing Fiu's code to this seem to mitigate the problem: image

TheGreatSageEqualToHeaven commented 6 months ago

Changing Fiu's code to this seem to mitigate the problem: image

@green-real

SnorlaxAssist commented 6 months ago

Try this instead

table_insert(instructionlineinfo, (abslineinfo[bit32_rshift(i, linegaplog2) + 1] or 0) + (lineinfo[i] or 0))

This should eliminate the error as we investigate the problem.