This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Creator's profile picture

Error resuming bios.lua

Started by Creator, 17 April 2015 - 07:12 PM
Creator #1
Posted 17 April 2015 - 09:12 PM
When I run the calculator app in OmniOS, I can press one button, but after that it says this: Error resuming bios.lua and something like: Try reinstalling computercraft. I don't know why this error keeps appearing, in the normal CC and CCEmuRedux. If you want to help me find out what does wrong, download OmniOS by typing this:

pastebin run zZgP0FeM OmniOS
and
OmniOS/BIOS.lua

Unlike the other programs, the calulator app uses NewInteract and not Interact. I did this as to preserve Interact, but still be able to test.

If you have any questions, be sure to ask me.

Thanks in advance,

-Creator
Bomb Bloke #2
Posted 18 April 2015 - 01:07 AM
For this one, methinks you'll want to define a global function like this:

function doDebugLog(stuff)
  local logfile = fs.open("log.txt","a")
  logfile.writeLine(stuff)
  logfile.close()
end

Thoughout your script files, you can then do this:

if doDebugLog then doDebugLog("reached such-and-such a section of code") end

This should allow you to narrow it down to the actual section that's triggering the problem.
Creator #3
Posted 18 April 2015 - 07:18 AM
Thanks, but I already have a log api. The problem come when I open the caluclator and press a button. The app stops responding and the pc shutsdown
Bomb Bloke #4
Posted 18 April 2015 - 07:49 AM
Great! And what has your logging API told you about exactly which part of your code is executing in the lead-up to the shut down?
Creator #5
Posted 18 April 2015 - 08:48 AM
I don't know, since it crashes somewhere before it gets logged. My logging system works like this: When a coroutine is ended/dead it logs the reason why it terminated. However, this error shuts down the whole cc PC so it can't log it. Have you downloaded OmniOS and experienced the error?
Creator #6
Posted 18 April 2015 - 09:06 AM
I had CCtweaks installed, maybe that was the problem.
Creator #7
Posted 18 April 2015 - 09:20 AM
Eve after emoving CCtweaks the error persists. The error only happens when I open the calculator app. Iscan press the buttons on the top bar, but when I press a number or anything else, calculator stops responding and and after some seconds, crashes.
Bomb Bloke #8
Posted 18 April 2015 - 12:38 PM
I don't know, since it crashes somewhere before it gets logged. My logging system works like this: When a coroutine is ended/dead it logs the reason why it terminated. However, this error shuts down the whole cc PC so it can't log it.

So implement more logging triggers! Keep adding 'em in until you know can narrow it down to the area where the fault is occurring, then start concentrating your logging on that area until you know the line which is to blame.

Have you downloaded OmniOS and experienced the error?

Yeah, though running it didn't trigger the error you initially described. Instead the system simply crashes, as though you're triggering yield protection - and the calculator doesn't seem to be the only app affected, either.

In short, I know enough to say that I'm not personally interested in doing the "grunt work" to narrow things down for you. The initial troubleshooting process here isn't hard, or complex; it's merely time consuming. If you're still stuck after figuring out the chunks of code which are actually at fault, then fine; list those out and we'll see where we go from there - but you're more than capable of doing the basic diagnostics yourself. Saying "here's hundred of lines of code, spread across a bunch of files, with a logical error in it… somewhere" isn't likely to get you quick answers.
Creator #9
Posted 18 April 2015 - 06:24 PM
I will do the narowing down and I would not ask you to do it since it is my program, but I will ask you to help me solve the problem if it above my knowledge.
Edited on 18 April 2015 - 06:20 PM
Creator #10
Posted 18 April 2015 - 08:23 PM
I have managed to take a screenshot of the error message:
biggest yikes #11
Posted 21 April 2015 - 12:25 AM
Would test, the desktop seems to crash every time I boot though
EDIT: Doesn't seem to even install now..
Edited on 20 April 2015 - 10:28 PM
HPWebcamAble #12
Posted 21 April 2015 - 02:04 AM
Tried in CCEmuRedux, doesn't show the error, just shuts down the computer
(Side note: Your 'OldSandbox.lua' has a half formed if statement and errors when it loads, line 89)

Like Bomb said, use a logging API


log("About to do stuff")
--# Do stuff
log("About to do more stuff")
--# Do more stuff

Have the log function use the 'flush()' function to save the file after every new message
Creator #13
Posted 21 April 2015 - 05:26 AM
What is the difference between close and flush? I abandoned OmniOS tjese days. Today I'll continue working on it.
Bomb Bloke #14
Posted 21 April 2015 - 05:52 AM
When the file is opened, the software doing the opening is marked by the host OS as having a handle on the file. This is often used to lock it, in order to prevent other programs from attempting to open and likewise modify the file. Having two programs working on the same file at the same time obviously won't work too well.

In this case, the "program" doing the opening is Java (because MineCraft told it to, because ComputerCraft told it to, because your script told it to…), and your host OS is probably Windows.

When you go to write data to a file, you would generally not actually "do the write" straight away. Instead, you might store the data in RAM, and when you've got enough of it, you'd write it all to the drive in one go. Telling your physical drive to go through a hundred different write operations is a lot slower than handing it a bunch of data to plonk down in one operation. This buffering system is handled for you automatically by LuaJ.

So the difference between close and flush - both request that what's queued up in the write buffer gets written to disk immediately (instead of waiting for the buffering system to decide to do it automatically, which is entirely unpredictable). Close also, however, drops the handle.

Not that if your script crashes while the handle is open, and the data to write is still buffered in RAM, odds are it won't get written at all! Hence why when attempting to log a crash, you'd want to force a flush after every line.
flaghacker #15
Posted 21 April 2015 - 05:53 AM
What is the difference between close and flush? I abandoned OmniOS tjese days. Today I'll continue working on it.

Flush saves the file without closing it. Close well… closes it. When using flush you don't have to reopen the file every time you save.

Edit: those ninja's nowadays…
Edited on 21 April 2015 - 03:55 AM
Creator #16
Posted 21 April 2015 - 06:35 AM
Well, after every log I close the file and thus save it. Thanks
Creator #17
Posted 21 April 2015 - 06:36 PM
I was at a friends and the version 15w16a did not crash, so I don't know waht is happening. Maybe I'll just jump back to 15w16a

In OmniOS, the API, I defined a function require. I guess it was the problem, since it is not crashing now.
flaghacker #18
Posted 21 April 2015 - 09:34 PM
I was at a friends and the version 15w16a did not crash, so I don't know waht is happening. Maybe I'll just jump back to 15w16a

In OmniOS, the API, I defined a function require. I guess it was the problem, since it is not crashing now.

That would probably be it, as require is a Lua keyword that is kinda replaced by os.loadAPI(). Maybe it causes some internal errors in computercraft.

If you manage to confirm require is the cause, that might make for a good bug report.
Creator #19
Posted 21 April 2015 - 09:37 PM
Well, the moment I removed it, OmniOS stopped crashing. I think require is a lu dafined function. So why does cc not crash when read is overwritten?
valithor #20
Posted 22 April 2015 - 05:12 AM
Well, the moment I removed it, OmniOS stopped crashing. I think require is a lu dafined function. So why does cc not crash when read is overwritten?

Require is actually part of lua, read is not. That is to say require is created using java and is in the actual langage, while read is defined in bios and a CC only type thing (it would be completely different outside of CC).

Now the only possible reason (I can think of) that this would cause a crash is if CC utilizes the function, which I find interesting overwriting it would cause a crash.
Edited on 22 April 2015 - 03:20 AM
KingofGamesYami #21
Posted 22 April 2015 - 01:40 PM
Wait, require exists in lua 5.1? Then why does the lua console say it's nil?
Creator #22
Posted 22 April 2015 - 02:43 PM
I think it is replaced by loadAPI or it is set to nil, but it is a lua function and that makes no sense since you actually can overwrite lua functions
Creator #23
Posted 24 April 2015 - 11:06 PM
Upon further investigation, I have found out what could possibly cause the problem. Here is a screenshot I managed to take the last moment.

Thanks in advance,

Creator

PS: I am sorry it is in google docs, but I have nowhere to host the images
Creator #24
Posted 24 April 2015 - 11:25 PM
Forgot to mention it happens when this file is loaded as an api and the function newEnv("hi") called.
Bomb Bloke #25
Posted 24 April 2015 - 11:57 PM
Here is a screenshot I managed to take the last moment.

So which function would that be referring to, in your version of ComputerCraft? printError?
HPWebcamAble #26
Posted 25 April 2015 - 12:52 AM
Around Line 129 of your 'Sandbox' file:


function globalEnv(tTable)
                if not type(tTable) == "table" then error("Expected table",2) end
                for i,v in pairs(tTable) do
                        local tType = type(v)
                        if tType == "table" then
                                globalEnv(v)
                        elseif tType == "function" then
                                setfenv(v,_G)
                        end
                end
        end

Line 128 should be this:

if type(tTable) ~= "table" then error("Expected table",2) end


In the last error pic on the google doc:

lua> Sandbox.newEnv("hi")
Sandbox:129: bad argument: table expected, got nil

Fixing the typo should tell us what calls the function with 'nil'
Creator #27
Posted 25 April 2015 - 10:23 AM
Thanks, I was half asleep when writting that. Eat a +1