payonel / ocvm

OpenComputer Emulator
41 stars 7 forks source link

basic_string::_M_construct null not valid when init.lua tries fs proxy #44

Closed Ocawesome101 closed 3 years ago

Ocawesome101 commented 4 years ago

Offending code:

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
Ocawesome101 commented 4 years ago

UPDATE:

What the hell? it works perfectly now...

Ocawesome101 commented 3 years ago

no activity for over a year and i haven't experienced this since; closing.