title: GDB execution error : argc=<value temporarily unavailable, due to optimizations>, argv=0x7fff5fbff8f8
body: <p>I've got a problem of execution with a C++ program. First of all, I'm working on a MacBook Pro, using native g++ to compile.</p>
  
  <p>My program builds an array of Record*. Each record has a multidimensional key. Then it iterates over each record to find its unidimensional float key.</p>
  
  <p>In the end, given an interval of two multidimensional keys, it determines if a given float corresponds to a multidimensional key in this interval. The algorithm is taken from a research paper, and it is quite simple in implementation.</p>
  
  <p>Until 100,000 values computed, no problem, the program does its job. But when I goes to 1,000,000 values, execution crashes.Here is the error given by g++ :</p>
  
  <pre><code>Program received signal EXC_BAD_ACCESS, Could not access memory.
  Reason: KERN_PROTECTION_FAILURE at address: 0x00007fff5f08dcd0
  0x00000001000021ab in TestPyramid () at include/indextree_test.cc:444
  </code></pre>
  
  <p>Here is the full backtrace given by gdb :</p>
  
  <pre><code>(gdb) backtrace full
  #0  0x00000001000021ab in TestPyramid () at include/indextree_test.cc:444
  test_records = #1  0x00000001000027be in main (argc=&lt;value temporarily unavailable, due to optimizations&gt;, argv=0x7fff5fbff8f8) at include/indextree_test.cc:83
  rc = &lt;value temporarily unavailable, due to optimizations&gt;
  progName = 0x7fff5fbff9f8 "/Users/Max/Documents/indextree_test"
  testNum = 4
  </code></pre>
  
  <p>Given lines are calls to the function.</p>
  
  <p>Here is a sample of code :</p>
  
  <pre><code>Record* test_records[1000000];
  float values[1000000];
  int base = 0;
  
  for (int i(0); i &lt; 1000000; i++)
  {
      test_records[i] = CreateRecordBasic(i%30+10,i+i%100,"ab","Generic Payload");
      if (i%30+10 &gt; base)
          base = i%30+10;
      if (i+10*i &gt; base)
          base = i+10*i;
      if (i &gt; base)
          base = i;
  }
  
  for (int i(0); i &lt; 1000000; i++)
      values[i] = floatValueFromKey(test_records[i]-&gt;key, base,num_char);
  </code></pre>
  
  <p>And in the end, I put the relevant float keys in a list.</p>
  
  <p>Is the problem a limitation of my computer ? Did I allocate the memory in a bad manner ?</p>
  
  <p>Thanks for your help,</p>
  
  <p>Max.</p>
  
  <p>Edit : </p>
  
  <p>Here is the code of CreateRecordBasic :</p>
  
  <pre><code>Record *CreateRecordBasic(int32_t attribute_1, int64_t attribute_2, const char* attribute_3, const char* payload){
      Attribute** a = new Attribute*[3];
  
      a[0] = ShortAttribute(attribute_1);
      a[1] = IntAttribute(attribute_2);
      a[2] = VarcharAttribute(attribute_3);
  
      Record *record = new Record;
      record-&gt;key.value = a;
      record-&gt;key.attribute_count = 3;
      SetValue(record-&gt;payload,payload);
  
      return record;
  }
  </code></pre>