LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   mmap: getting SIGBUS when writing to a position that is bellow what I requested (https://www.linuxquestions.org/questions/programming-9/mmap-getting-sigbus-when-writing-to-a-position-that-is-bellow-what-i-requested-4175421085/)

eantoranz 08-08-2012 05:32 PM

mmap: getting SIGBUS when writing to a position that is bellow what I requested
 
So!

I'm working with shared memory.

I have requested mmap to get me shared memory of a given size to write onto:

Code:

char * sharedMemory = mmap(0, memorySize, PROT_WRITE, MAP_SHARED, sharedMemFd, 0xf0000);
(taken from other shared memory examples, guys). Now, memorySize is o ver 6*10^6 at the time.... but when I try to do memcpy on it I get a SIGBUS. I isolated the index where the problem is happening and it's on char index 5169152. Why is that? Is there a max value that can be mmapped or something?

Thanks in advance.

kauuttt 08-09-2012 04:12 AM

Couple of things, we may try/check:

1) Change the 1st parameter to mmap() to NULL or any valid address.
2) Cross-check the value of 'memorySize'.

eantoranz 08-09-2012 10:04 AM

The problem was the offset I was using: 0xf0000 (taken straight from the examples). I needed them to be in 0 and now it's working like a charm. Thanks for your kind help anyway.


All times are GMT -5. The time now is 09:44 PM.