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: 
belltown
Roku Guru

[Bug Report] How to Crash My Roku

The following program, or at least the second line of it, crashes my Roku 3100X running version 5.5 - build 410:


sub main ()
dim a[1e9]
end sub


Note that dim a[1e10] gives an Out Of Memory error and dim a[1e8] seems to work just fine.
0 Kudos
7 REPLIES 7
destruk
Binge Watcher

Re: [Bug Report] How to Crash My Roku

Could be because 1e8 is 488 (decimal), and 1e10 is 7696
That's a lot of difference.
I wonder why 489 crashes it though. - what message does it give you for that one?
What if you use decimal dimension statements? Do those work?
0 Kudos
belltown
Roku Guru

Re: [Bug Report] How to Crash My Roku

"destruk" wrote:
Could be because 1e8 is 488 (decimal), and 1e10 is 7696
That's a lot of difference.
I wonder why 489 crashes it though. - what message does it give you for that one?
What if you use decimal dimension statements? Do those work?

1e8 is 100000000 (95.367MB)*
1e9 is 1000000000 (953,674 MB)
1e10 is 10000000000 (9536,743MB)

* - I'm assuming Dim a allocates x bytes of memory. However, the manual just uses the term 'elements' without defining the actual size of the 'elements' allocated.

The Roku's stated memory capacity is 256MB.

And, yes, I get the same result if I use decimal numbers: Dim a[1000000000] causes a re-boot, too. (But Dim a[1e9] makes for a shorter re-boot command!)

Dim a[1e8] works because it is within the available memory limit.
DIm a[1e10] gives an Out Of Memory error because it exceeds the available memory limit.
Dim a[1e9] should also give an Out Of Memory error, as it too exceeds the available memory limit; instead, it crashes the Roku device.
0 Kudos
destruk
Binge Watcher

Re: [Bug Report] How to Crash My Roku

That's useless. I mean although you can dim 1e8 successfully, as soon as you begin 'loading data' into the array it also kills/reboots the roku.
Maybe Roku isn't designed for using hundreds of millions of array entries...who would have thought?
0 Kudos
belltown
Roku Guru

Re: [Bug Report] How to Crash My Roku

The reason I'm bringing this up is because if the Roku crashes when trying to allocate memory, then there just might be a problem with the way it allocates memory.

Several users in the other thread with the same model and firmware version as mine have reported that their Roku reboots for no apparent reason. Random users experiencing random re-boots can be a hard problem to pinpoint. However, the re-boot situation I mentioned here is repeatable 100% of the time and should be an easier problem to track down, which may in turn lead the engineers down a path that could help them identify the cause of other users' crashes.

I don't really need to allocate an array with 1000000000 elements. I was just trying to find a way to fill up my Roku's memory so I could test what happens to my code when memory is scare: is there some kind of memory allocation error that my code would need to handle, does the channel just crash, or does the whole Roku crash? It seems the latter two options are the most likely.
0 Kudos
destruk
Binge Watcher

Re: [Bug Report] How to Crash My Roku

You could take this as an apology - first I was thinking 1e8 was a hex instead of float. Next I posted that even though it doesn't kill the roku on dim[1e8] - as soon as you begin setting values of that dim'd array it crashes.
So what I would think is the problem here, isn't really a problem - it's that the memory allocation of an array is dynamic (as it should be) depending on what you are storing in the array.
If anything, the 'bug' is that if you put imaginary useless test constructs into your code, it displays an out of memory error as it is obviously unable to process the command.
Such as dim [infinity] - Ha Ha, you got me, I'll display an out of memory error for that. It probably shouldn't display any error whatsoever on a dim statement until you try to use the created array - which would catch these types of impossibilities.

It would be more useful to troubleshoot/debug, etc, to figure out how much memory is available to the roku sandbox for a side-loaded application, and then determine how much a single character takes when assigned to an array - without that information, your actual usable limit for your construct could be 25mb, 5mb, 250mb, we're just guessing, and it could vary by roku model like the available temp storage - still not useful.
0 Kudos
belltown
Roku Guru

Re: [Bug Report] How to Crash My Roku

I don't really need to know the actual limit of how much memory is available; I'm sure it would vary too much from model to model, user to user, etc. I just want, as a worse case scenario, that if I try to exceed that limit (or do anything that the Roku doesn't like) then my channel will crash, rather than have the whole Roku crash. I would think that would be an embarrassment for Roku to have their whole device crash due to other people's software bugs (or their own bugs), just as I would be embarrassed if my code crashed due to one of my bugs.
0 Kudos
EnTerr
Roku Guru

Re: [Bug Report] How to Crash My Roku

This YAWRR is very close to what was discussed here viewtopic.php?f=34&t=69733&p=440878#p440878

PS. FWIW, `dim a[1e9]` does not crash fw3.
0 Kudos