title: Deletion of Pointers Issue
body: <p>I am having trouble deleting my pointers that I have created.  The program creates a double pointer to point to the threads.  Then it creates threads dynamically.  At the end it deletes them but I am getting a glibc error.  It uses boost to create the threads. What is really puzzling is that I delete a similar double pointer the same exact way and that executes fine. The issue is at the end of the code block under the heading of <code>/*clean up*/</code>:</p>
  
  <pre><code>boost :: thread** thrds;
  
  //create threads and bind to p_variantforloop_t
  thrds = new boost::thread*[numThreads];
  
  for (int i = 1; i &lt;= numThreads; i++)
      thrds[i] = new boost::thread(boost::bind(&amp;p_variantforloop_t, 
          E, A, D, (i*n-n)/i ,(i*n)/n, numThreads, n)); 
  
  /* join threads */
  for (int i = 0; i &lt; numThreads; i++)
      thrds[i]-&gt;join();
  
  /* cleanup */
  for (int i = 0; i &lt; numThreads; i++)
      delete thrds[i];
  delete[] thrds;
  </code></pre>
  
  <p>the error is:</p>
  
  <blockquote>
    <p><code>*** glibc detected *** ./hw9: munmap_chunk(): invalid pointer: 0x0957d480 ***</code><br/>
    <code>======= Backtrace: =========</code><br/>
    <code>/lib/tls/i686/cmov/libc.so.6(+0x6b591)[0x264591]</code><br/>
    <code>/lib/tls/i686/cmov/libc.so.6(+0x6c80e)[0x26580e]</code><br/>
    <code>/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0x529741]</code><br/>
    <code>./hw9[0x804a0d1]</code><br/>
    <code>/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0x20fbd6]</code><br/>
    <code>./hw9[0x8049871]</code><br/>
    <code>======= Memory map: ========</code><br/>
    <code>001f9000-0034c000 r-xp 00000000 08:02 1128663    /lib/tls/i686/cmov/libc-2.11.1.so</code><br/>
    <code>0034c000-0034d000 ---p 00153000 08:02 1128663    /lib/tls/i686/cmov/libc-2.11.1.so</code><br/>
    <code>0034d000-0034f000 r--p 00153000 08:02 1128663    /lib/tls/i686/cmov/libc-2.11.1.so</code><br/>
    <code>0034f000-00350000 rw-p 00155000 08:02 1128663    /lib/tls/i686/cmov/libc-2.11.1.so</code><br/>
    <code>00350000-00353000 rw-p 00000000 00:00 0</code><br/>
    <code>0046e000-00557000 r-xp 00000000 08:02 982712     /usr/lib/libstdc++.so.6.0.13</code><br/>
    <code>00557000-00558000 ---p 000e9000 08:02 982712     /usr/lib/libstdc++.so.6.0.13</code><br/>
    <code>00558000-0055c000 r--p 000e9000 08:02 982712     /usr/lib/libstdc++.so.6.0.13</code><br/>
    <code>0055c000-0055d000 rw-p 000ed000 08:02 982712     /usr/lib/libstdc++.so.6.0.13</code><br/>
    <code>0055d000-00564000 rw-p 00000000 00:00 0</code><br/>
    <code>005ad000-005d1000 r-xp 00000000 08:02 1130719    /lib/tls/i686/cmov/libm-2.11.1.so</code><br/>
    <code>005d1000-005d2000 r--p 00023000 08:02 1130719    /lib/tls/i686/cmov/libm-2.11.1.so</code><br/>
    <code>005d2000-005d3000 rw-p 00024000 08:02 1130719    /lib/tls/i686/cmov/libm-2.11.1.so</code><br/>
    <code>00950000-00965000 r-xp 00000000 08:02 1130743    /lib/tls/i686/cmov/libpthread-2.11.1.so</code><br/>
    <code>00965000-00966000 r--p 00014000 08:02 1130743    /lib/tls/i686/cmov/libpthread-2.11.1.so</code><br/>
    <code>00966000-00967000 rw-p 00015000 08:02 1130743    /lib/tls/i686/cmov/libpthread-2.11.1.so</code><br/>
    <code>00967000-00969000 rw-p 00000000 00:00 0</code><br/>
    <code>00a67000-00a7a000 r-xp 00000000 08:02 176445     /usr/lib/libboost_thread.so.1.40.0</code><br/>
    <code>00a7a000-00a7b000 r--p 00013000 08:02 176445     /usr/lib/libboost_thread.so.1.40.0</code><br/>
    <code>00a7b000-00a7c000 rw-p 00014000 08:02 176445     /usr/lib/libboost_thread.so.1.40.0</code><br/>
    <code>00bc7000-00be2000 r-xp 00000000 08:02 1128318    /lib/ld-2.11.1.so</code><br/>
    <code>00be2000-00be3000 r--p 0001a000 08:02 1128318    /lib/ld-2.11.1.so</code><br/>
    <code>00be3000-00be4000 rw-p 0001b000 08:02 1128318    /lib/ld-2.11.1.so</code><br/>
    <code>00c34000-00c3b000 r-xp 00000000 08:02 1130745    /lib/tls/i686/cmov/librt-2.11.1.so</code><br/>
    <code>00c3b000-00c3c000 r--p 00006000 08:02 1130745    /lib/tls/i686/cmov/librt-2.11.1.so</code><br/>
    <code>00c3c000-00c3d000 rw-p 00007000 08:02 1130745    /lib/tls/i686/cmov/librt-2.11.1.so</code><br/>
    <code>00ccf000-00cd0000 r-xp 00000000 00:00 0          [vdso]</code><br/>
    <code>00e85000-00ea2000 r-xp 00000000 08:02 1128359    /lib/libgcc_s.so.1</code><br/>
    <code>00ea2000-00ea3000 r--p 0001c000 08:02 1128359    /lib/libgcc_s.so.1</code><br/>
    <code>00ea3000-00ea4000 rw-p 0001d000 08:02 1128359    /lib/libgcc_s.so.1</code><br/>
    <code>08048000-0804e000 r-xp 00000000 00:1d 10184      /home/tparisi/Desktop/source_code_hw5/hw9</code><br/>
    <code>0804e000-0804f000 r--p 00005000 00:1d 10184      /home/tparisi/Desktop/source_code_hw5/hw9</code><br/>
    <code>0804f000-08050000 rw-p 00006000 00:1d 10184      /home/tparisi/Desktop/source_code_hw5/hw9</code><br/>
    <code>0957d000-0959e000 rw-p 00000000 00:00 0          [heap]</code><br/>
    <code>b68bf000-b68c0000 ---p 00000000 00:00 0</code><br/>
    <code>b68c0000-b70c0000 rw-p 00000000 00:00 0</code><br/>
    <code>b70c0000-b70c1000 ---p 00000000 00:00 0</code><br/>
    <code>b70c1000-b78c4000 rw-p 00000000 00:00 0</code><br/>
    <code>b78e8000-b78eb000 rw-p 00000000 00:00 0</code><br/>
    <code>bfc07000-bfc1c000 rw-p 00000000 00:00 0          [stack]</code><br/>
    <code>Aborted</code><br/></p>
  </blockquote>