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

  • Home
  • SEARCH
  • 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 7982723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:45:23+00:00 2026-06-04T10:45:23+00:00

Label_Info is just a trivial class with some int members: class Label_Info { public:

  • 0

Label_Info is just a trivial class with some int members:

class Label_Info {
public:
    Label_Info();
    unsigned int x, x1, x2, y, y1, y2, size;
};

Label_Info::Label_Info() {
    this->x = this->y = this->size = 0;
    this->x1 = this->y1 = -1;
    this->x2 = this->y2 = 0;
}

Then, compiled with gcc:

std::map<unsigned int, Label_Info> labels_info;
unsigned int label = 1;
Label_Info *label_info = &labels_info[label];

Very rarely, I am stopped by an access violation on the third line. As I understand it, what’s going on is the std::map inserts a new Label_Info for the key 1 and then a pointer to that is label_info. Then (at least when it doesn’t crash!) I can access the members like this:

label_info->x = 25;

… and so on. I receive no access violation for perhaps 1,000,000 inserts, then, suddenly, bam. I checked the usual suspects: 32-bit threshold and out of memory, and everything looks OK on the insert when it detonates. I know it’s an insertion because I can see it going through that STL std::map code in the debugger but I can’t read it well enough to tell what it’s trying to access for the insertion.

So is this code bad news? Any insight from folks who know more about C++ than me would be appreciated. Thanks.

  • 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-04T10:45:26+00:00Added an answer on June 4, 2026 at 10:45 am

    The code that you’ve shown us should be perfectly fine. However there is almost certainly other code you aren’t showing us that either directly causes the problem, or more likely just causes memory corruption in certain circumstances and when it hits just right the maps breaks.

    If you can compile your codebase on Linux there’s a good chance that valgrind can find the memory bug for you.

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

Sidebar

Related Questions

a develop a application. in this we take data from server just like name,
Just ran into this recently and I thought it'd be helpful to share. The
I have a label on my asp.net page, it looks like this: more info
just started using AndroidQuery for JSON asynchronous tasks and Im not familiar with JSON
I have come across a problem I just can't solve. I am using autocomplete
This is something thats been hard for me to find info on, I was
I have just started to work with jquery so I need to make sure
i have just started learning linq because i like the sound of it. and
I've been playing with a sample application I found online. Just changing things to
I've got a problem using pyExcelerator when reading some xls-files. There're some python scripts

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.