Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8951105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:35:08+00:00 2026-06-15T13:35:08+00:00

I recently ran into a crash in my code where I was unsure of

  • 0

I recently ran into a crash in my code where I was unsure of how and why it was crashing and began using static analyizers, then I began using Intel Inspector XE 2013. I kept running into the same “Invalid memory access” in my code so I began to reduce my code to the smallest possible form to get it to reproduce, where I finally got to a point where it seems that there is an “Invalid memory access” in my code but only if my class has a destructor. The interesting this is that my “Invalid memory access” is happening on an address that is before the address it is trying to delete. The code that ended up “Invalid memory access” is not actually crashing my code, but I thought I would fix this potential issue encase it was having a snowball affect. My code in question is

class Group {
public:
    Group() {}
    ~Group() {} // When this line is not here, there will not be an "Invalid memory access"
};

int main() {
    Group** groups = new Group*[3];

    groups[0] = new Group();
    groups[1] = new Group();
    groups[2] = new Group();

    for(unsigned int i = 0; i < 3; ++i)
        delete [] groups[i];

    delete [] groups;

    return 0;
}

The “Invalid memory access” problem will be flagged on the first time it tries “delete [] group[i]” (so i will be equal to 0). The memory address that it is a flagged at is “0x003e30ec” where as group[0] is actually “0x003e30f0”, which is 0x4 ahead. Whenever I run this test, it is consitantly at a difference of 0x4.

My question is, is there actually anything wrong with my code where I am reading or writing to memory improperly or is this person just a bad result from Intel Inspector XE 2013 (I am on Visual Studio 2012 Update 1)?

For those curious about my memory table with the example above, it is the following

groups == 0x003e30b8
groups[0] == 0x003e30f0
groups[1] == 0x003e3120
groups[2] == 0x003e3150
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:35:09+00:00Added an answer on June 15, 2026 at 1:35 pm
    for(unsigned int i = 0; i < 3; ++i)
            delete [] groups[i];
    

    should be

    for(unsigned int i = 0; i < 3; ++i)
            delete  groups[i];
    

    new/delete, new [] /delete [] should always match. In your case just use std::vector<std::shared_ptr<Group> > groups; will be a better way.

    where I finally got to a point where it seems that there is an
    “Invalid memory access” in my code but only if my class has a
    destructor.

    using wrong delete[] is why your application is crashing, it has nothing to do with your destructor in this case, unless you have something hidden in your destructor but that will be another bug.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently ran into a bug in my code when using boost::bind . From
I recently ran into an issue that could easily be solved using modulus division,
I recently ran into code that looks like this: next { 'foo' => bar,
I recently ran into a problem with a COM object that was using a
Premise I recently ran into a bug in a select statement in my code.
I'm writing a C parser using PLY, and recently ran into a problem. This
I recently ran into a problem caused by using fstream::eof(). I read the following
I've recently ran into some code that checks Page.IsCallBack but I wasn't sure how
G'day, I was using Test::Class perl module for some testing recently and ran into
I recently ran into a problem where it seems I need a 'static abstract'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.