Cannot access memory at address on vectors

738 views
Skip to first unread message

Stefanos Bakirtzis

unread,
May 1, 2017, 4:59:48 PM5/1/17
to ns-3-users
Hi all,
I have created a class called SetApp. In these class, I declared several vectors, when I try to access any element of these vectors in the debugger I always  get this msg '' Cannot access memory at address 0x68 ( or whatever the memory of the vector is ) ". I have searched a lot but I couldn't find any solution. I would be really gratefull if anyone could help me how to fix this, or suggest any idea
Here is a small sample of the code
class SetApp  : public Object
{
public:

static TypeId GetTypeId (void);
   SetApp ();
  virtual ~SetApp ();
   ...
  std::vector <int> Active
  std::vector <int> Exit;
};
...
SetApp::SetApp ()
  :
    CarsNumber(0),
    m_CAMPacketSize(400), 
    m_CumulativeThroughput(0),
    m_E2E(0),
    m_MyDelay(0),
    m_TotalCars(0),
    m_MyPDR(0),
    m_nNodes (100),
    Active(100,0),
    Exit(100,0),
    m_NoL(100,0),
    m_Optional(100, 0),
    InRange(100, m_Optional)
{

}

Tommaso Pecorella

unread,
May 1, 2017, 6:54:40 PM5/1/17
to ns-3-users
Hi,

probably the debugger is complaining because it can not access the vector memory just because the memory is corrupt.
If you're looking after a bug (segmentation fault or similar) remember that the last stack levels might be corrupt, where the number of levels corrupted are depending on the actual bug. Go up in the stack 'til you find something that makes sense.

T.

Stefanos Bakirtzis

unread,
May 2, 2017, 6:15:33 AM5/2/17
to ns-3-users
Dear Tommaso
That was my first thought when I received the segmentation fault. Looking upwards to the stack to find the problem (that made sense for me ), I saw that the problem occurred when I was trying to access my vectors. 
I was really surprised at this because I have used vectors in the exact same way before and there wasn't any error. I don't know if you had across with smth like this before, anyway thank
you very much for you response . 
Reply all
Reply to author
Forward
0 new messages