mmap() causes Segmentation Fault for more than 1024 bytes

Started by curator23, April 26, 2015, 08:41:44 PM

Previous topic - Next topic


Hi there,

I have an Olinuxino-IMX233-nano. I'm running the latest Olimex archlinux image (image version 4; Linux alarm 2.6.35-8-ARCH+ #1 PREEMPT Fri Sep 21 17:02:25 UTC 2012 armv5tejl GNU/Linux).

I'm experimenting with TV-out and the frame buffer. I have succeeded in writing to frame buffer using:
fb = open("/dev/fb0", O_RDWR);
write(fb, mybuffer, mybuffer_size * sizeof(int));

however, this seems to give rather poort performance, so I followed this example:

however, the call
screen_mem =  mmap (addr, buffer_size, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0);
causes a segmentation fault if buffer_size is greater than 1024.

This seems to be an issue related to mmap, because if I simply allocate some memory like so:
mem =  mmap (NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
The same problem occurs.

And the weird thing is that it simply prints "Segmentation Fault" to the console, with no additional information, and nothing registers in dmesg.

(I also need to figure out why the screen goes blank after a few minutes, how to stop tty0 from displaying on fb0, why mplayer can't play a PAL resolution divx avi at full speed, and why top reports 0KiB total swap... but all in good time ;))

Thank you for your time.


Yes... gpio-mmap.h works. And today my original code works also... huh? The only difference is that yesterday it was raining.

After reboot, `top` reports momeroy usage as:
KiB 60628 total, 25380 used, 35248 free

with my program running
KiB 60628 total, 25748 used, 34880 free

after stopping with Ctrl-C
KiB 60628 total, 25652 used, 34976 free,

Is that a memory leak?
At this point its looking like an earlier version of my program which had attempted to allocate 11MB (forgot to convert from bits_per_pixel to bytes_per_pixel) may have swamped the memory... although I could've sworn I'd rebooted  a couple of time to rule that out yesterday.

Ok, so I've just tested that idea, and while attempting to allocate 11MB instead of 1.5MB does cause a Segmentation Fault, it does not persist when the task is killed and restarted with the correct memory size.

So I don't know what the problem was, but I don't have it anymore.

Thanks for your help.