LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 08-08-2012, 06:32 PM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Rep: Reputation: 83
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.
 
Old 08-09-2012, 05:12 AM   #2
kauuttt
Member
 
Registered: Dec 2008
Location: Kolkata, India
Distribution: Ubuntu
Posts: 123

Rep: Reputation: 25
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'.
 
Old 08-09-2012, 11:04 AM   #3
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Original Poster
Rep: Reputation: 83
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.
 
  


Reply

Tags
mmap, shared memory, shnm_open


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help on writing a string into a file in a particular position ajaygowni Programming 4 07-28-2012 09:12 AM
Need help on writing a string into a file in a particular position ajaygowni Linux - General 3 07-28-2012 07:53 AM
Difficulty in writing in a file through mapping using MMAP puneet193128 Programming 1 11-18-2009 03:59 PM
mips SIGBUS crash, suggestions requested kapsikum Programming 3 01-24-2009 05:13 AM
writing a resume for a research position Four General 2 12-25-2006 01:40 PM


All times are GMT -5. The time now is 11:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration