Basalt icon indicating copy to clipboard operation
Basalt copied to clipboard

bug: DEV branch; basalt.debug crashes when called inside a thread

Open MasonGulu opened this issue 2 years ago • 4 comments

What happened?

Attempt to debug a thread by displaying a value using basalt.debug crashes the program.

Computercraft client

CraftOSPC

Relevant log output

I wish this was copypastable

basalt.lua:2209: Thread Error Occured - cannot resume running coroutine

2209 in eventHandler
713 in eventHandler
71 in cab (one of the minified functions)
this was in an xpcall
80 in autoUpdate

Latest Basalt Version

  • [X] I use the latest stable version

MasonGulu avatar Oct 22 '22 05:10 MasonGulu

Hm, it is hard for me to reproduce the error. When i use basalt.debug inside a running thread it works fine. Also using error or "text"..nil errors as expected.

The log output you showed here tells me that the currently running thread trys to resume the thread. Can you show me the code? Full code or important code part. On pastebin/devbin or whatever.

Also a sidenote you could use basalt.logging = true this should start to log errors into a file named basaltLogs.txt - but keep an eye on file size :P

NoryiE avatar Oct 22 '22 07:10 NoryiE

Hi, here's a recreation of the crash setup, ~~this actually doesn't crash how I expected it to. I was expecting a crash upon clicking the button, but with this setup it crashes the first time the thread is ran.~~ Edited to fix this, it now crashes upon clicking the button.

local basalt = require("basalt")

local main = basalt.createFrame():setTheme({FrameBG = colors.lightGray, FrameFG = colors.black})

main:addButton():setText("Crash"):setSize("parent.w - 2", "parent.h - 2"):setPosition(2,2):onClick(function()
  os.queueEvent("anEvent")
end)

main:addThread():start(function ()
  while true do
    os.pullEvent("anEvent")
    basalt.debug(5)
  end
end)

basalt.autoUpdate()

MasonGulu avatar Oct 22 '22 16:10 MasonGulu

Oh it doesn't crash how I was expecting it to because I didn't wrap the queueEvent call in a function

MasonGulu avatar Oct 22 '22 17:10 MasonGulu

Hey, thank you! This example helped me alot. It should be fixed 5cf5347

The problem was because of dynamic value also queues a event. This is now disabled by default.

NoryiE avatar Oct 22 '22 20:10 NoryiE