For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > March 2006 > mmap segmentation fault









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author mmap segmentation fault
Aloha

2006-03-28, 10:00 pm

Hi, All:

I had a strange problem trying to get a handle of it.

The program is written in c, compiled by gcc 2.8.1 and run on solaris
8.

There is a memory mapped file used to work fine, but recently the file
size is increased from 250M to 260M, though mmap() returns fine. The
following code suddenly doesn't work anymore.

struct someStruct *somePointer = mmap(...);

somePointer->firstMember.secondMember = 0; /* this line does not work
anymore */

however *(&somePointer->firstMember.secondMember) = 0; /* this line
works! */

Any clue?

I make sure that the file size is big enough, so the write doesn't
excess the file.

Regards

Andrei Voropaev

2006-03-30, 4:00 am

On 2006-03-29, Aloha <betterLuckThanSmart@yahoo.com> wrote:
[...]
> somePointer->firstMember.secondMember = 0; /* this line does not work
> anymore */
>
> however *(&somePointer->firstMember.secondMember) = 0; /* this line
> works! */

[...]

Check the assembler that is generated for both lines, see what's the
difference. Otherwise nobody can tell you what could be wrong. You may
change some other thing in some other part of your program, and never
think about it :)


--
Minds, like parachutes, function best when open
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com