I was developing a module on the Flic Hub using the Flic Hub SDK. The module sends out all button presses as UDP messages.
While working on the module, I noticed a strange bug, which I assume is a firmware issue - when sending the 36th UDP message, the module crashes with a
FATAL ERROR:
uncaught: 'cannot push beyond allocated stack'
I made a minimal module that will reproduce the bug consistently:
var dgram = require("dgram");
function SendJSON(data)
{
try {
udp = dgram.createSocket("udp4");
udp.send(data, 32768, "127.0.0.1", function(err) {
console.log("UDP sent. Return: " + err);
udp.close();
});
} catch(e) {
console.log("Error sending button state!");
}
};
var i = 0;
var myInt = setInterval(function() {
i ++;
console.log("Sending packet " + i);
SendJSON("" + i + " ");
}, 100);
Flic Hub SDK Console output:
Sending packet 1
UDP sent. Return: null
Sending packet 2
UDP sent. Return: null
Sending packet 3
UDP sent. Return: null
[...]
Sending packet 34
UDP sent. Return: null
Sending packet 35
UDP sent. Return: null
Sending packet 36
FATAL ERROR:
uncaught: 'cannot push beyond allocated stack'
I consider this a firmware bug because of the following reasons:
- the "fatal error" is not catched by the try-catch block
- the module is still considered "running" even after the crash (the SDK's "play" button stays in "can be stopped" state)
Is there any solution to this?