Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
EnTerr
Roku Guru

Why is it so easy to crash Roku in debugger?

I was learning B/S debugger basics today and have to say find it jaw-dropping how easy it is to crash Roku with only a few keystrokes (5, if i count them: "a\nda\n"). Here is how it looks:
BrightScript Debugger> a
Syntax Error. (compile error &h02) in $LIVECOMPILE(229)

BrightScript Debugger> da
070: Sub WaitMessage(port) As Object
071: while true
J000 81 pushbool true
90 01 iffalse J001 'addr=25
...
229: a

Connection to host lost.

Whoops, what happened? Not only did i get kicked out of the console but in a few seconds the whole box reboots. What a mess!

It was not my intent to crash it. At first thought it randomly reboots when in console, took me a while to pinpoint a sequence. Seems that any syntax error followed at any time later by 'da' causes it. i am guessing because there is invalid opcode, disassembler does not know how to handle (or 0 length or some such).

But it is creepy, it means i'd have to be vewy, vewy careful what i type in the console or sudden death is imminent. How do i even clear such condition without reboot?
0 Kudos
11 REPLIES 11
RokuJoel
Binge Watcher

Re: Why is it so easy to crash Roku in debugger?

You just found a bug. It really isn't that common to crash the debugger like that. Looks like that issue exists on 4.2 and not on 3.1

- Joel
0 Kudos
EnTerr
Roku Guru

Re: Why is it so easy to crash Roku in debugger?

"RokuJoel" wrote:
You just found a bug. It really isn't that common to crash the debugger like that. Looks like that issue exists on 4.2 and not on 3.1

Yes, i know it is a bug. I get it only in rOS4 too, which is mildly disturbing (why is there a schism in non-architecture dependent code base?). I would expect bugs in the console, yes - it's not a place QAs would be sent to test but reboot, really - can't exit with more grace to home screen?
0 Kudos
EnTerr
Roku Guru

Re: Why is it so easy to crash Roku in debugger?

RokuCo,
would you please consider fixing this, so that player does not crash? Was bug ever entered on this?

This crash happens very reliably (on 3xxx series) - it is more reliable than ctrl-C entering debugger mode (since often ctrl-C exits dev channel for no raisin). All that is needed is issuing "da" (to see the bytecode) after there has been "Syntax Error" on previous command - reboot happens when listing reaches the position where syntax error was. My semi-wild-ass guess is part of a structure remains uninitialized / with random stack data. Glance at the 3rd number of the "ld", normally it is the offset of line's last bytecode - not so for lines 99-102:
...
096: 398, 399, 0x1e4bb60, end sub
097: 000, -01, (nil),
098: 400, 404, 0x1e4bb60, ?
099: 405, 000, 0x1e4bb60, {}
100: 405, 1970040879, 0x1e4bb60, wild_ass
101: 405, 1769104752, 0x1e4bb60, SWAG
102: 405, 1936028265, 0x1e4bb60, {}

I must be one of only a few around looking at bytecode, since i don't see others complained in two years. Occasionally I find it educational/enlightening though - for example let me understand why/how "eval()" is leaking.
0 Kudos
destruk
Streaming Star

Re: Why is it so easy to crash Roku in debugger?

I don't think many developers type random nonsensical commands into the debugger console...Still would be neat to have the sandbox actually behave like a sandbox rather than a current application running in an application debugger session within a second sandbox.
0 Kudos
EnTerr
Roku Guru

Re: Why is it so easy to crash Roku in debugger?

😞 Nobody is typing "random nonsensical commands into the debugger console" -
since there could not be auto-complete and edit capabilities are very limited (only backspace, no prev.line recall), one is bound to make a typo sooner or later.

Also, crash happens even without ever been syntax error - today i was trying to answer my own question and... behold!
BrightScript Debugger> f = function(x): return x+1: end function
BrightScript Debugger> da
042: sub Main()
... [snip unrelated] ...
100: f =
8a 00 26 pushfun #$anon_f0f
aa 10 00 poplocal f
af end
b0 01 array [sp-1]
Connection closed by foreign host.
No typos, perfectly legit yet this one crashes both firmwares, 5 and 3.

Is there a bug entered on the debugger crashes?
0 Kudos
RokuJoel
Binge Watcher

Re: Why is it so easy to crash Roku in debugger?

Yes, I filed a bug on this exact issue on 12/31/2011 against firmware 4.x

I'm pretty sure you don't even need a syntax error to reproduce, copy paste from the bug report:

side load a BrightScript channel. Telnet to the device on port 8085. Press ctrl-c to interrupt the program and exit to the debugger.

At the BrightScript prompt type:
BrightScript Debugger> a

press enter

then type:
BrightScript Debugger> da

press enter.

...this appears to cause the device to reboot.


- Joel
0 Kudos
EnTerr
Roku Guru

Re: Why is it so easy to crash Roku in debugger?

"RokuJoel" wrote:
Yes, I filed a bug on this exact issue on 12/31/2011 against firmware 4.x

I'm pretty sure you don't even need a syntax error to reproduce, copy paste from the bug report:

Thanks, good to know at least it was reported.

FWIW, that example relied on syntax error happening (as seen in the first topic of thread). Today's development is that crash may occur without an error/typo - and both fw3 and fw5 (before it was only the new fw). It might be a different bug even.

I understand this may never be fixed as matter of priorities; albeit bothered it's likely something trivial like missed else or default case.
0 Kudos
TheEndless
Channel Surfer

Re: Why is it so easy to crash Roku in debugger?

"EnTerr" wrote:
😞 Nobody is typing "random nonsensical commands into the debugger console"

More likely that nobody is typing "da" into the debugger console. I type random nonsensical commands all the time. I just don't ever try to view the bytecode. 😉
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
ljunkie
Visitor

Re: Why is it so easy to crash Roku in debugger?

FWIW, I usually hit ctrc-c once the channel starts loading to verify it won't crash while I want to debug something, or if I have an implicit stop in the code. I'm guessing most have seen the pattern, but it will crash the debugger every other time.
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.