Error when testing onboard application: device reports readiness to read but returned no data (device disconnected?)

I wrote a motion planning algorithm and implemented it as an onboard application. I am testing the algorithm on the Pixhawk Mini. To test the application, I am accessing the nsh console via mavlink (./Tools/mavlink_shell.py /dev/ttyACM0).

The app starts off fine, but after a few seconds, this appears on the console (after which the console exits):

device reports readiness to read but returned no data (device disconnected?)

which is cryptic to me. Any ideas?

Could this have to do with overflow? My algorithm eats up a lot of memory as it runs, so the timing - that the algorithm runs fine for a few seconds before I get this error - hints at this…