By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,412 Members | 978 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,412 IT Pros & Developers. It's quick & easy.

Receiving error "SEGV_MAPERR - Address not mapped to object"

P: n/a
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 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Mar 16, 9:46 am, klaritydef...@yahoo.co.in 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-lit...t.html#faq-5.8

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

http://www.parashift.com/c++-faq-lit....html#faq-10.6

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

http://www.parashift.com/c++-faq-lit....html#faq-34.1

Cheers! --M

Mar 16 '07 #2

P: n/a
On Mar 16, 10:57 pm, "mlimber" <mlim...@gmail.comwrote:
On Mar 16, 9:46 am, klaritydef...@yahoo.co.in 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-lit...t.html#faq-5.8

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

http://www.parashift.com/c++-faq-lit....html#faq-10.6

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

http://www.parashift.com/c++-faq-lit....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 '07 #3

P: n/a
On 19 Mar, 13:05, klaritydef...@yahoo.co.in wrote:
On Mar 16, 10:57 pm, "mlimber" <mlim...@gmail.comwrote:
On Mar 16, 9:46 am, klaritydef...@yahoo.co.in wrote:
Hi,
I am receving the following error when I run my application (build onC
++ 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-lit...t.html#faq-5.8
BTW, you should probably be using an initializer list instead of
assignment. See:
http://www.parashift.com/c++-faq-lit....html#faq-10.6
You might also consider using a std::vector rather than an array:
http://www.parashift.com/c++-faq-lit....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

Mar 19 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Browse more C / C++ Questions on Bytes