Could not allocate memory
Opened this issue · 5 comments
>sudo -s
# ./pi_pcm
Using mbox device /dev/vcio.
Could not allocate memory.
Terminating with signal 0
This was working up until just recently (likely today). This might have been the result of an update or 2, though I have no specific hunches.
My debug skills with c are very rudimentary, but I determined from some print edits that it's this line that the memory error is coming from:
Lines 470 to 472 in bfc74a4
...
Well, actually... a restart seems to have fixed this issue and it is working again... so feel free to close, but I'm going to post to see what you think was going on here... It might happen again, and may indicate some underlying issue I should look into?
Huh. This has happened again... Must be related to a system update I made? This has been stable for years. Now every time I try to use it, I get the vcio memory allocation error.
I luckily had made the backup on a separate Micro SD card right before the updates. I switched back to the pre-update SD card a few days ago and the problem appears to have gone away. I presume that the problem still exists on the other SD card. I need to make another backup (and overwrite that card) since that one apparently has a problem, but it would be nice to know what the problem is.
I don't know exactly what updates I performed, though I know I had performed the updates by installing npm_check to see what was outdated. I was just doing some updates for good measure - no specific reason. It's possible that one of the updates breaks pi_rc on an rPi 3B+, but could it also just be possible that my Pi is overloaded?
Is there a way to compare the 2 disk images to see what's different?
I think I have narrowed in on the cause of the problem. It may be related to ioctl:
Lines 89 to 93 in bfc74a4
I don't see the error in the above code, which suggests that the result must be 0 or positive. This code requires it to be non-zero (positive):
Lines 470 to 472 in bfc74a4
but since it is printing the error, it must be 0. However, mem_alloc only returns zero if ioctl returns negative:
Line 120 in bfc74a4
but it can't be negative since the error in mbox_property didn't print:
Line 92 in bfc74a4
This seems impossible, unless p[5]
is 0. I suppose p[5]
can be 0 if this is zero:
Line 243 in bfc74a4
I don't see how that can sometimes be, from an npm update...
Well, this happened again recently after having gone back to a backup, so I'm stumped as to what's causing it. It seems less frequent since going back to the backup, so maybe I've just somehow got too much running on my pi? Memory usage is not anywhere near maxed out.