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 6102281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:35:47+00:00 2026-05-23T13:35:47+00:00

I am getting a strange heap corruption error during the application close where if

  • 0

I am getting a strange heap corruption error during the application close where if a “std::vector” is present in my code, AND I am deleted my “ref_count” variable. If I don’t have an std::vector, there is no crash. If there is a std::vector and I don’t delete the ref_count (causing a memory leak), then there is a heap crash. I am made my test case as small as possible, but unfortunately it is too big for here so it is located at http://codepad.org/USIPjPHJ . Does anyone have any suggestions on what could be the problem?

I will get a crash with the heap exception of this in my output windows.


HEAP[CrashTest.exe]: HEAP: Free Heap block 6d4c30 modified at 6d4c58 after it was freed
Windows has triggered a breakpoint in CrashTest.exe.

This may be due to a corruption of the heap, which indicates a bug in CrashTest.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while CrashTest.exe has focus.

The output window may have more diagnostic information.


My IDE is Visual Studio 2010 SP1 (tried on non SP1 also) but that should not be causing the issue.

  • 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-05-23T13:35:47+00:00Added an answer on May 23, 2026 at 1:35 pm

    This line:

    strong_ref<int> reg1;
    

    sets *ref_count to 0 (because ptr == NULL), then this line:

    strong_ref<int> copy1(reg1);
    

    increments *ref_count to 1.

    On exit, the destructor is called twice (once for reg1, once for copy1). The first time, *ref_count is decremented to 0 and ref_count is deallocated, leaving a dangling reference for the second time.

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

Sidebar

Related Questions

I'm getting some strange behaviour from EF Code First when I add an object
I'm getting a strange error, and I cannot figure out the problem. I'm sending
I've been getting strange compiler errors on this binary search algorithm. I get a
I'm getting strange navigation bar behaviour, for example when I hit back button the
I followed the example SSO on Facebook's developer website but am getting a strange
Please help me understand why this isn't working. I don't know if there is
I'm populating datagrid with collection of anonymous types (I'm setting DataGrid's DataContext property). And
I'm using OpenGL to draw in 2D. I'm trying to overlay textures with alpha.
We just got a new Windows 2008 R2 server and I am trying to
I'm just putting the finishing touches on a project I've been working on to

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.