payonel / ocvm

OpenComputer Emulator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Ocawesome101 opened this issue · comments

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

UPDATE:

What the hell? it works perfectly now...

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