local address, proxy = computer.getBootAddress(), component.invoke
local rootfs = component.proxy(address)
local handle = assert(rootfs.open("/boot/bootmgr.lua"))
local data = ""
-- hangs in this loop, generates 'basic_string::_M_construct null not valid' error on TLWOY
repeat
local chunk = rootfs.read(handle, math.huge) -- value of 2048 behaves the same
data = data .. (chunk or "")
until not chunk
rootfs.close(handle)
assert(xpcall(assert(load(data, "=OpenNT Boot Manager", "bt", _G)), debug.traceback, address))
This is a very weird error. The following code works perfectly.
local addr, invoke = computer.getBootAddress(), component.invoke
local kernelPath = "/boot/bootmgr.lua"
local handle, err = invoke(addr, "open", kernelPath)
if not handle then
error(err)
end
local t = ""
repeat
local c = invoke(addr, "read", handle, math.huge)
t = t .. (c or "")
until not c
invoke(addr, "close", handle)
local ok, err = load(t, "=" .. kernelPath, "bt", _G)
if not ok then
kernel.logger.panic(err)
end
local ok, err = xpcall(ok, debug.traceback, addr)
if not ok and err then
error(err)
end
Offending code:
This is a very weird error. The following code works perfectly.