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

Need help finding the cause of a null pointer exception

Started by Immolus, 31 March 2017 - 10:19 AM
Immolus #1
Posted 31 March 2017 - 12:19 PM
Hello, I asked this on reddit and was directed to post here.

Monitor setup 8 wide x 3 high
Computer setup
Error

The code I've written:
Info Panel - startup
powermeter
Remote Computer - startup

Minecraft 1.7.10 (Single Player)
ComputerCraft 1.75

I've only been using CC and learning lua for 3 days and after much searching and trying various things to fix it. Sometimes it will run for hours just fine before it throws the error, others just a few seconds after rebooting the computer.

Any help/insight would be appreciated.
FuzzyLitchi #2
Posted 31 March 2017 - 05:17 PM
Well this is no normal lua error, this a an error in the computercraft mod, or other mods. I will look into how this happend.

Does this happen when anything specific happens, or is it a general error?
Immolus #3
Posted 31 March 2017 - 05:39 PM
Well this is no normal lua error, this a an error in the computercraft mod, or other mods. I will look into how this happend.

Does this happen when anything specific happens, or is it a general error?

As far as I know it just happens randomly. Given enough time it happens. There doesn't seem to be anything in particular that triggers it.

At one point I thought it was coming from GC lag spikes, but I've ruled that out by watching it crash no where near one of those. I can hop dimensions and come back to find it still running. I've also tried different monitor sizes (and rendering sizes of the powermeter to match). I've also increased the sleep time on the computers sending data to the infopanel.

Right now I'm using a loop a user posted in an unrelated thread to keep the infopanel running along with a counter to keep track of how often it crashes.



peripheral.call("right", "clear")
c = 0
while true do
  term.clear()
  term.setCursorPos(1,1)
  term.write("infopanel has crashed " .. c .. " time(s).")

  shell.run("infopanel")

  c=c+1
end
FuzzyLitchi #4
Posted 31 March 2017 - 07:28 PM
Just to be sure, the error is thrown by the Monitor setup computer, right?
Immolus #5
Posted 31 March 2017 - 11:28 PM
Just to be sure, the error is thrown by the Monitor setup computer, right?

Correct, I provided all the remote computer code just to give the whole picture of my setup. I've yet to see either of the remote computers crash back to the command line.
Bomb Bloke #6
Posted 01 April 2017 - 10:53 AM
It's possible that this project might allow you to extract some more information about the source of the error.
Immolus #7
Posted 01 April 2017 - 11:39 AM
this a an error in the computercraft mod, or other mods.

I've got some thoughts on this. The screenshots in my opening post, the computers are located in the Aroma mining dimension. After a clean boot of minecraft and starting a creative world for testing. I recreated the setup and I've yet to have a problem with crashing while in the Minecraft overworld. I only let that run for about four hours so I can't say it is conclusive that the Aroma mining dimension mod has something to do with it.


It's possible that this project might allow you to extract some more information about the source of the error.

Thanks, loaded and running in my survival world now. I'll post any output when it pops up. Also I believe you're the user that posted the code I quoted above that effectively keeps my info panel rebooting after a crash.
Immolus #8
Posted 01 April 2017 - 12:37 PM
It's possible that this project might allow you to extract some more information about the source of the error.
Trace output
Edit: Another crash


Updated files:
infopanel
powermeter
Edited on 01 April 2017 - 11:24 AM
Bomb Bloke #9
Posted 01 April 2017 - 02:46 PM
You could edit the code around line 95 in powermeter to produce further output, maybe. Eg:

local ok, err = pcall(mon.write, " ")

if not ok then error("Failure to write to monitor; x/y: "..i..", "..y..", clr: "..clr) end

I do think it'd pay to refactor your code to use string.rep() and term.blit(), though. All of this "drawing single characters at a time" business adds up to some pretty slow execution, especially when you consider that ComputerCraft has to update entire lines every time you perform any write operations.
Immolus #10
Posted 01 April 2017 - 04:08 PM
You could edit the code around line 95 in powermeter to produce further output, maybe. Eg:

local ok, err = pcall(mon.write, " ")

if not ok then error("Failure to write to monitor; x/y: "..i..", "..y..", clr: "..clr) end
Done, I'll report anything that shows up.

refactor your code to use string.rep() and term.blit()

I'll work on doing this.
Immolus #11
Posted 02 April 2017 - 01:04 PM
local ok, err = pcall(mon.write, " ")

if not ok then error("Failure to write to monitor; x/y: "..i..", "..y..", clr: "..clr) end

I scrapped that code when other monitor calls started throwing the error instead. I rewrote it from the ground up using string.rep() and term.blit(). It was interesting buffering the screen with 3 tables of strings.

I'd like to say thank you to you and FuzzyLitchi for your time and help.