Receiving error "SEGV_MAPERR - Address not mapped to object"

K

klaritydefect

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?
 
M

mlimber

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
 
K

klaritydefect

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
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

On Mar 16, 9:46 am, (e-mail address removed) 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:

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

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

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top