Receiving error "SEGV_MAPERR - Address not mapped to object"

Discussion in 'C++' started by klaritydefect@yahoo.co.in, Mar 16, 2007.

  1. Guest

    Hi,

    I am receving the following error when I run my application (build on C
    ++ code)

    Program received signal SIGSEGV, Segmentation fault
    si_code: 1 - SEGV_MAPERR - Address not mapped to object.

    I debug using gdb to find the error and located the position where it
    is throwing an error

    MyFile.h
    -------------
    const int MAX_VALUE = 10000;
    class MyClass
    {
    public:
    MyClass();
    virtual ~MyClass();
    class InnerClass
    {
    public:
    InnerClass() { }
    ~InnerClass() { }
    };

    private:
    InnerClass arrObj[MAX_VALUE];
    InnerClass *ptrObj;
    };

    MyFile.cpp
    ----------------
    #include "MyFile.h"
    MyClass::MyClass()
    {
    ptrObj = arrObj; // Error is thrown at this line
    ....
    }
    ....

    I don't find anything wrong with the code. Could anyone tell me why am
    I getting this signal?
    , Mar 16, 2007
    #1
    1. Advertising

  2. mlimber Guest

    On Mar 16, 9:46 am, wrote:
    > Hi,
    >
    > I am receving the following error when I run my application (build on C
    > ++ code)
    >
    > Program received signal SIGSEGV, Segmentation fault
    > si_code: 1 - SEGV_MAPERR - Address not mapped to object.
    >
    > I debug using gdb to find the error and located the position where it
    > is throwing an error
    >
    > MyFile.h
    > -------------
    > const int MAX_VALUE = 10000;
    > class MyClass
    > {
    > public:
    > MyClass();
    > virtual ~MyClass();
    > class InnerClass
    > {
    > public:
    > InnerClass() { }
    > ~InnerClass() { }
    > };
    >
    > private:
    > InnerClass arrObj[MAX_VALUE];
    > InnerClass *ptrObj;
    >
    > };
    >
    > MyFile.cpp
    > ----------------
    > #include "MyFile.h"
    > MyClass::MyClass()
    > {
    > ptrObj = arrObj; // Error is thrown at this line
    > ....}
    >
    > ...
    >
    > I don't find anything wrong with the code. Could anyone tell me why am
    > I getting this signal?


    I don't see anything wrong with the snippet you show. Chances are,
    it's a pointer error at some (possibly unrelated) part of the code
    that is causing it. Post a *minimal* but *complete* program (that is,
    one that has all the code and only that code) that demonstrates your
    problem. See:

    http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.8

    BTW, you should probably be using an initializer list instead of
    assignment. See:

    http://www.parashift.com/c -faq-lite/ctors.html#faq-10.6

    You might also consider using a std::vector rather than an array:

    http://www.parashift.com/c -faq-lite/containers.html#faq-34.1

    Cheers! --M
    mlimber, Mar 16, 2007
    #2
    1. Advertising

  3. Guest

    On Mar 16, 10:57 pm, "mlimber" <> wrote:
    > On Mar 16, 9:46 am, wrote:
    >
    >
    >
    >
    >
    > > Hi,

    >
    > > I am receving the following error when I run my application (build on C
    > > ++ code)

    >
    > > Program received signal SIGSEGV, Segmentation fault
    > > si_code: 1 - SEGV_MAPERR - Address not mapped to object.

    >
    > > I debug using gdb to find the error and located the position where it
    > > is throwing an error

    >
    > > MyFile.h
    > > -------------
    > > const int MAX_VALUE = 10000;
    > > class MyClass
    > > {
    > > public:
    > > MyClass();
    > > virtual ~MyClass();
    > > class InnerClass
    > > {
    > > public:
    > > InnerClass() { }
    > > ~InnerClass() { }
    > > };

    >
    > > private:
    > > InnerClass arrObj[MAX_VALUE];
    > > InnerClass *ptrObj;

    >
    > > };

    >
    > > MyFile.cpp
    > > ----------------
    > > #include "MyFile.h"
    > > MyClass::MyClass()
    > > {
    > > ptrObj = arrObj; // Error is thrown at this line
    > > ....}

    >
    > > ...

    >
    > > I don't find anything wrong with the code. Could anyone tell me why am
    > > I getting this signal?

    >
    > I don't see anything wrong with the snippet you show. Chances are,
    > it's a pointer error at some (possibly unrelated) part of the code
    > that is causing it. Post a *minimal* but *complete* program (that is,
    > one that has all the code and only that code) that demonstrates your
    > problem. See:
    >
    > http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.8
    >
    > BTW, you should probably be using an initializer list instead of
    > assignment. See:
    >
    > http://www.parashift.com/c -faq-lite/ctors.html#faq-10.6
    >
    > You might also consider using a std::vector rather than an array:
    >
    > http://www.parashift.com/c -faq-lite/containers.html#faq-34.1
    >
    > Cheers! --M- Hide quoted text -
    >
    > - Show quoted text -


    Hi,

    We changed the size of array value from 10000 to 1000 and it worked
    fine. But now we get the same error in other place.

    We thought there could be some deficiency in stack size and increased
    the size of the kernel parameter "maxssiz_64bit" to a maximum value
    and still we persist with the same problem.

    Our application is build on HP-UX 11.23 IPF 64-bit platform and the
    compiler version we use is A.06.10.

    Thanks,
    Thiagu
    , Mar 19, 2007
    #3
  4. On 19 Mar, 13:05, wrote:
    > On Mar 16, 10:57 pm, "mlimber" <> wrote:
    >
    >
    >
    > > On Mar 16, 9:46 am, wrote:

    >
    > > > Hi,

    >
    > > > I am receving the following error when I run my application (build on C
    > > > ++ code)

    >
    > > > Program received signal SIGSEGV, Segmentation fault
    > > > si_code: 1 - SEGV_MAPERR - Address not mapped to object.

    >
    > > > I debug using gdb to find the error and located the position where it
    > > > is throwing an error

    >
    > > > MyFile.h
    > > > -------------
    > > > const int MAX_VALUE = 10000;
    > > > class MyClass
    > > > {
    > > > public:
    > > > MyClass();
    > > > virtual ~MyClass();
    > > > class InnerClass
    > > > {
    > > > public:
    > > > InnerClass() { }
    > > > ~InnerClass() { }
    > > > };

    >
    > > > private:
    > > > InnerClass arrObj[MAX_VALUE];
    > > > InnerClass *ptrObj;

    >
    > > > };

    >
    > > > MyFile.cpp
    > > > ----------------
    > > > #include "MyFile.h"
    > > > MyClass::MyClass()
    > > > {
    > > > ptrObj = arrObj; // Error is thrown at this line
    > > > ....}

    >
    > > > ...

    >
    > > > I don't find anything wrong with the code. Could anyone tell me why am
    > > > I getting this signal?

    >
    > > I don't see anything wrong with the snippet you show. Chances are,
    > > it's a pointer error at some (possibly unrelated) part of the code
    > > that is causing it. Post a *minimal* but *complete* program (that is,
    > > one that has all the code and only that code) that demonstrates your
    > > problem. See:

    >
    > >http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.8

    >
    > > BTW, you should probably be using an initializer list instead of
    > > assignment. See:

    >
    > >http://www.parashift.com/c -faq-lite/ctors.html#faq-10.6

    >
    > > You might also consider using a std::vector rather than an array:

    >
    > >http://www.parashift.com/c -faq-lite/containers.html#faq-34.1

    >
    > > Cheers! --M- Hide quoted text -

    >
    > > - Show quoted text -

    >
    > Hi,
    >
    > We changed the size of array value from 10000 to 1000 and it worked
    > fine. But now we get the same error in other place.
    >
    > We thought there could be some deficiency in stack size and increased
    > the size of the kernel parameter "maxssiz_64bit" to a maximum value
    > and still we persist with the same problem.
    >
    > Our application is build on HP-UX 11.23 IPF 64-bit platform and the
    > compiler version we use is A.06.10.


    I suppose it can depend on how you use the MyClass object, if you try
    to create an instance on the stack I imagine that you could get a
    stack overflow.

    Is there a reason to have an array as a member of the object *and*
    having a pointer to the array? Can't you just have the pointer and
    allocate the array on the heap using new int the constructor?

    --
    Erik Wikström
    =?iso-8859-1?q?Erik_Wikstr=F6m?=, Mar 19, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob G
    Replies:
    2
    Views:
    2,237
    Rob G
    May 24, 2004
  2. =?Utf-8?B?U2VhbiBXLg==?=
    Replies:
    3
    Views:
    5,110
    Jeffrey Palermo [MCP]
    Nov 25, 2004
  3. Replies:
    2
    Views:
    779
    Bruce Barker
    Oct 24, 2005
  4. ThunderMusic
    Replies:
    0
    Views:
    521
    ThunderMusic
    Jan 3, 2006
  5. riloo
    Replies:
    0
    Views:
    783
    riloo
    Apr 27, 2004
Loading...

Share This Page