473,785 Members | 2,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Segementation Problem while accessing contents from Memory Mapped File

Hi,

I have a following structure:
typedef struct
{
RateData rdr;
int RateID;
char RateBalance;
} RateInfo;
typedef struct
{
DayRates *dr;
WeekRates *wr;
} TimeOfDayRates;

First I will create the memoefy for the DayRates, WeekRates structures
inside the RateInfo structure variable. After that Iam going to copy
the contents into DayRates, WeekRatesstruct ures. Once the all the
structure members inside RateInfo structure variable are initialized, I
will add that node to a AVL tree. This way, Iam going to create an AVL
tree by adding RateInfo nodes to it. Once the total tree is contructed,
I will store this tree as file (rateinfo.map) on the disk.

In my next programming component, Iam going to load this file
(rateinfo.map) into memory using mmap() function call. Once I load the
file into memory using mmap(), Iam able to access the RateID and
RateBalance members of the RateInfo. But, Iam not able to access the
DayRates, and WeekRates structure contents. When I try to access the
members of DayRates , and WeekRates structures, my program is showing
segmentation fault and Iam getting the core dump.

Even though I allocated memory for DayRates , and WeekRates structures
inside RateInfo node while creating the tree, why Iam not able to
access contents of DayRates , and WeekRates structures when I mmap()
file into memory?

Any pointers would be a great help.

Thanks,
-Nikhil

Jan 10 '06 #1
3 2357
Please find the correct structure declarations:
typedef struct
{
RateData rdr;
int RateID;
char RateBalance;

} RateInfo;

typedef struct
{
DayRates *dr;
WeekRates *wr;

} RateData;

Jan 10 '06 #2
nk******@gmail. com writes:
[snip]
In my next programming component, Iam going to load this file
(rateinfo.map) into memory using mmap() function call. Once I load the
file into memory using mmap(), Iam able to access the RateID and
RateBalance members of the RateInfo. But, Iam not able to access the
DayRates, and WeekRates structure contents. When I try to access the
members of DayRates , and WeekRates structures, my program is showing
segmentation fault and Iam getting the core dump.

Even though I allocated memory for DayRates , and WeekRates structures
inside RateInfo node while creating the tree, why Iam not able to
access contents of DayRates , and WeekRates structures when I mmap()
file into memory?


There is no mmap() function in standard C (it's defined by POSIX, a
separate standard). You'll need to ask in a newsgroup for your
system, perhaps comp.unix.progr ammer.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jan 10 '06 #3
In article <ln************ @nuthaus.mib.or g>,
Keith Thompson <ks***@mib.or g> wrote:
There is no mmap() function in standard C (it's defined by POSIX, a
separate standard).


True, but his real problem was in trying to use a pointer created
in one execution in a different execution. He could have just
read() the same data into a block of memory and tried to use it,
to the same failed effect. mmap() was a red herring in this problem.
--
I was very young in those days, but I was also rather dim.
-- Christopher Priest
Jan 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2424
by: Peter Nolan | last post by:
Hi All, I have some software that currently loads database tables into sorted arrays in memory to be binary searched by processes. (Long story as to why it does this..) Each process must either read the data from the in memory array or from the database itself if the table is too large to be loaded into memory. (2GB is usually the limit because the array is indexed by a 32 bit signed integer. I have never had one of these tables go over...
16
2891
by: Justin Lazanowski | last post by:
Cross posting this question on the recommendation of an I have a .NET application that I am developing in C# I am loading information in from a dataset, and then pushing the dataset to a grid, or other controls depending on the particular form. This application is setup with one MDI parent calling MDI children with the exception of one Modal form (the report viewer). When I run the application and run one of the screens that pulls...
5
21570
by: Niloday | last post by:
Hi All, I am trying to access a mapped network drive from a service that I have created. The service needs to create/delete folders/files on a network drive. When I tried to connect to a folder on mapped network drive (eg. N:\Storage that corresponds to \\FS1NS\SharedDir\), I get an error as "Could not find part of path N:\".
0
275
by: nkrisraj | last post by:
Hi, I have a following structure: typedef struct { RateData rdr; int RateID; char RateBalance; } RateInfo;
8
3022
by: nkrisraj | last post by:
Hi, I have a following structure: typedef struct { RateData rdr; int RateID; char RateBalance; } RateInfo;
13
2761
by: Samshayam | last post by:
I have come across the application of placement new in memory mapped i/o in a number of books.I am not able to understand it completely, may be becaues of my lack of knowledge with memory mapped i/o.In my understanding it is a system where I/O devices are treated as memory locations and are addressed using same number of address lines.How an object placed at a specific location makes a difference to this?Some body pls clarify?
45
4466
by: Dennis | last post by:
Hi, I have a text file that contents a list of email addresses like this: "foo@yahoo.com" "tom@hotmail.com" "jerry@gmail.com" "tommy@apple.com" I like to
1
3914
by: Chris Brooks | last post by:
Hi, I would like to read directly from a tar file into memory so I can manipulate a file (quickly) and write its changes out to another file. I thought I could do something like: #!/usr/bin/env python import tarfile import mmap
0
1378
by: Chris Brooks | last post by:
Jean-Paul Calderone wrote: Actually, I want the contents of the tar uncompressed and untarred. So, for example, I might be working with image data that has to go through several transformations. I essentially want to pull the image out of the gz'ed tar and into memory so I can work on it (as a file) and later write the changed contents to somewhere else. But I don't really want to uncompress/untar and save the file to disk and then...
0
9481
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10341
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9954
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8979
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.