Project will randomly crash and output a C error

Hi,

I’m running into an issue where I get C errors intermittently when I run my project:

For background:
I’m currently working on a project where I’m utilizing a Raspberry Pi Zero with an Adafruit Hat to connect to an Azure Queue and display “scenes” it grabs from the queue to display on the board. Scenes are basically text marquees, static text, animations, or a rainbow transition.

This is the latest code I’m using to power the screen: https://thomasca.visualstudio.com/RGB%20Screen%20With%20Queue/_git/RGB%20Screen%20With%20Queue?version=GBhaving-matrix-sync-drive-events&path=%2FHelpers%2FScreenHelper.ts

And this is the current wire-up I’m using:

I’m using the latest version of DietPi with sound disabled and bluetooth uninstalled, and I’m using the typescript binding from alexeden/rpi-led-matrix. I’m also using the same hardware as this project: https://howchoo.com/pi/diy-raspberry-pi-nhl-scoreboard-led-panel.

Only difference I made is that I changed the screen out for this: https://www.amazon.com/gp/product/B07SDMWX9R/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1&fpw=alm

The issue I’m seeing:
Every so often when I start the project, the program will either error out after a few seconds, or show a few scenes, then flicker and crash. Every time, it reports a C error like the following:

“corrupted size vs. prev_size
Aborted”

or

“node: malloc.c:4028: _int_malloc: Assertion `(unsigned long) (size) >= (unsigned long) (nb)’ failed.
Aborted”

After that, the program quits and the screen goes blank (sometimes it glitches before doing so).

I tried changing the program to refresh the screen after every afterSync callback (in the typescript binding), and tried refreshing scenes based on timing. Both approaches seem to result in the same crash. I also tried different configurations, but it either is just as stable as before or less so.

It’s very intermittent. Sometimes it will display everything correctly with no errors. But this is a bit rare.

I’m not really sure what I’m doing wrong here or if maybe I just have something configured incorrectly.

sorry for the silly question, but are you sure you’re not running out of memory, maybe due to a memory leak?
I use this in my makefile to track those problems:

# To get memory debugging:
# unset LD_PRELOAD ; export ASAN=yes; make
# https://github.com/google/sanitizers/wiki/AddressSanitizer
ifneq ($(ASAN),)
CFLAGS += -fsanitize=address
CXXFLAGS += -fsanitize=address
LDFLAGS += -fsanitize=address
endif

See https://clang.llvm.org/docs/AddressSanitizer.html

Also, I run my code under gdb and run ‘bt’ when it crashes to see exactly where, why, and what’s the current state

Hi!

Actually, I decided to go a different direction on this. Using Node.JS on a Raspberry Pi Zero just didn’t seem to be very stable, no matter what I did.

So instead, I went with the C# binding in the rpi-rgb-led-matrix and expanded it to render the animations I wanted. This works with zero crashes now. I’m guessing the TypeScript/Node.JS binding was doing something that a lightweight raspberry pi just couldn’t handle.

I got my code changes here: thomascampbelladams/rpi-rgb-led-matrix. I’m still cleaning them up and will probably do a PR back to hzeller’s repo if the changes are useful to anyone else.

Sure, if it’s a clean addition of new bindinds, I’m sure @hzeller will be happy with a PR, as it can help others.