rpi-rgb-led-matrix
rpi-rgb-led-matrix copied to clipboard
Magick: abort due to signal 11 (SIGSEGV) "Segmentation Fault" important
hello master
i your library -> included in my own project -> layered
In general, it works very well, I get 250 fps with 6 panels, which is quite enough. I don't always get the error but in between visual transitions Magick: abort due to signal 11 (SIGSEGV) "Segmentation Fault" I'm getting errors like what exactly is this error, why?
parts of my code
gif player func
void gif_canvas(short dx, short dy, std::vector<Magick::Image> &imgs_, const Magick::Image &img_)
{
static size_t w = 0;
size_t img_size = imgs_.size();
w++;
if (w == img_size)
{
w = 0;
}
for (size_t y = dy; y < img_.rows(); ++y)
{
for (size_t x = dx; x < img_.columns(); ++x)
{
const Magick::Color &c = imgs_[w].pixelColor(x, y);
off_canvas->SetPixel(x, y,
ScaleQuantumToChar(c.redQuantum()),
ScaleQuantumToChar(c.greenQuantum()),
ScaleQuantumToChar(c.blueQuantum()));
}
}
}
scenes
readImages(&scene1, "../images/scene1.gif");
Magick::coalesceImages(&scene1_scenes, scene1.begin(), scene1.end());
readImages(&scene2, "../images/scene2.gif");
Magick::coalesceImages(&scene2_scenes, scene2.begin(), scene2.end());
readImages(&scene3, "../images/scene3.gif");
Magick::coalesceImages(&scene3_scenes, scene3.begin(), scene3.end());
while loop
while (!interrupt_received)
{
device_1.serial_read();
switch (device_1.step)
{
case 1:
device_1.play_music(1);
off_canvas->Clear();
device_1.step = 2;
break;
case 2:
device_1.gif_canvas(0, 0, scene1_scenes, scene1[0]);
break;
case 3:
device_1.gif_canvas(0, 0, scene2_scenes, scene2[0]);
break;
case 4:
device_1.gif_canvas(0, 0, scene3_scenes, scene3[0]);
break;
case 5:
device_1.gif_canvas(0, 0, scene4_scenes, scene4[0]);
break;
default:
break;
}
// device_1.pic_canvas(35, 70, imgt);
rgb_matrix::DrawText(off_canvas, device_1.font1, 7, 50, mRed, NULL, "TEOMAN", 5);
// device_1.ImgPaint(off_canvas,"scene1rsz.gif",0);
off_canvas = matrix->SwapOnVSync(off_canvas);
}
@hzeller i think i found the problem i don't get segmentation error for now i pulled the static size_t variable to the global area and reset it before every new image playback I don't understand why the w variable is overflowing even though it resets it every time
You use 4 vectors assuming they are all the same length in scenes. You also assume the scenes are the same size.
You defined a global state variable which is supposed to check this. If you move from 5 scenes per image down to 3 scenes per image there will be an issue. Use the correct operator which is >=.
Note I somewhat prefer the solution you used. I know C++ disagrees with this. However if you are doing this on embedded systems in C this would be slightly more desirable. Granted this is smaller RAM footprint on non-Linux systems. I have seen people really abuse this badly.
The issue with encapsulation here is that it hides how much global RAM is being used. (However the linker will still track it down for you.) You can declare it static to hide the symbol from external linkage to restrict it to the file. C++ class technically provides this by private variables. However C could emulate with struct.
It is more of a C thing really. This kind of mixes up the notion of static function with non-static function, kind of. It can get weird to say the least. This right here is an example of the issue that can be caused.