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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:14:16+00:00 2026-06-09T12:14:16+00:00

I was working with some openFrameworks examples when I got a memory access error.

  • 0

I was working with some openFrameworks examples when I got a memory access error. After a day of narrowing the problem down I have a pretty small sample of relatively pure C++ code which still causes a memory access error. I’ll post the whole thing here since it’s decently short.

There are three files: testApp.cpp, main.cpp, and testApp.h.

testApp.h:

#include <cstdlib>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
class X {
public:

  X();
  virtual ~X();

private:

  vector<string> vertices;
  vector<string> colors;
  vector<string> normals;
  vector<string> texCoords;
  vector<string> indices;
  bool bVertsChanged, bColorsChanged, bNormalsChanged, bTexCoordsChanged, bIndicesChanged;
  int mode;
  string name;

  bool useColors;
  bool useTextures;
  bool useNormals;
};

class testApp{

public:
  void setup();

  X x1;
  X x2;
  vector<string> stroke;
};

testApp.cpp:

#include "testApp.h"

X::X() {}
X::~X() {}

void testApp::setup(){
  std::cout << stroke.size() << std::endl;


}

main.cpp:

#define _GLIBCXX_DEBUG
#include "testApp.h"

int main( ){

    testApp* o = new testApp();
    o->setup();
    std::cout << o->stroke.size() << std::endl;

}

To compile, I typed: g++ -o testApp testApp.cpp main.cpp. (I’m using Ubuntu 12.04 with the stock g++ compiler version 4.6.3, x86_64 architecture). When I run it, I get this output:

18446744073709025734
0

The first number comes from calling testApp::setup, which prints out stroke.size() (which is obviously incorrect). The second number comes from printing stroke.size() directly. It seems like there’s some sort of memory issue, but I don’t know where to begin, or where to file a bug.

This seems to happen only when the testApp class is specified exactly like it was. If you comment out a single vector (or even a bool) the problem goes away. The problem also goes away if you comment out _GLIBCXX_DEBUG, but that flag is supposed to be benign AFAIK. Any advice? Where should I file a bug? Or is there something obvious I’ve overlooked?

Also, would anyone mind trying this on their own computer/compiler to see if they get the same problem?

  • 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-09T12:14:18+00:00Added an answer on June 9, 2026 at 12:14 pm

    _GLIBCXX_DEBUG likely changes the definitions of the Standard Library containers, so your program violates the One Definition Rule (ODR). The definition of X is different in the main.cpp translation unit and in the testApp.cpp translation unit, yielding undefined behavior.

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

Sidebar

Related Questions

I have a strange problem with Eclipse (Helios). After a few hours of working
This is a very strange problem: after working some time with Eclipse Juno and
I have been working using openFrameworks, on a problem that is posted on the
I've been re-working some code due to a memory leak. The code is part
Working on some code for a machine problem; we've just started working with pointers,
After working on some test code for open ID authentication, I had a break
I have some working code with a crutch to add BOM marker to a
i have attached TinyScrollBar(from [here] ) plugin with my project. It was working some
I have some working url with unicode and trying to apply IDNA encoding test
I am working on some legacy code, and I have the following wonderful issue.

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.