title: *** Error: double free or corruption (out): 0x00007fffe3465010 ***.Warning: Corrupted shared library list: 0x7ffea4000920 != 0x7ffff7ffd9d8
body: <pre><code>void *insert_rear_node(void *arg)
  {   
    int *argument=(int *)arg;
    int value=*argument;
    //Assume that allocation is happening fine (Just like malloc , it is a custom heap allocator)
  
    struct Node *head=(struct Node *) RTallocate(RTpointers, sizeof(struct Node));
    struct Node *temp;
    setf_init(temp,head);
  
    while(value&gt;0)
      {
        if(temp==NULL)
          {
            RTwrite_barrier(&amp;(temp), new_node(value,NULL));
            RTwrite_barrier(&amp;(head),temp);
            printf("Inserted %d into the list\n",head-&gt;data);
          }
        else
          {
            RTwrite_barrier(&amp;(temp),head);
            while(temp-&gt;next!=NULL)
              {
                RTwrite_barrier(&amp;(temp),temp-&gt;next);
              }
            RTwrite_barrier(&amp;(temp-&gt;next),new_node(value,NULL));
            printf("Inserted %d into the list\n",temp-&gt;next-&gt;data);
          }
        value=value-1;
  
      }
    free(head);
  
  }
  
  int main(int argc, char *argv[])
  {                                                                                                                                                                                                                              
    long heap_size = (1L &lt;&lt; 28);
    long static_size = (1L &lt;&lt; 26);
    printf("heap_size is %ld\n", heap_size);
    RTinit_heap(heap_size, static_size, 0);                                                                                                                                                                                                                 
    pthread_t thread1;                                                                                                                                                                                                                                   
    int limit=1000;
    RTpthread_create(&amp;thread1,NULL,insert_rear_node,(void *)&amp;limit);
  }
  </code></pre>
  
  <p>Assume that RTallocate and RTwrite_barrier are 2 custom functions which work perfectly fine.
  RTallocate - allocates memory on the heap
  RTwrite_barrier is equivalent to an assignemnt statement.</p>
  
  <p>This program simply insert nodes into a linkedlist.
  Then attempts to delete the head.</p>
  
  <blockquote>
    <p>I get this error:<br>
    <strong>Error in `/home/test/RT-Test/InMul': double free or corruption (out): 0x00007fffe3465010</strong> <br>
    warning: Corrupted shared library list:
    0x7ffea4000920 != 0x7ffff7ffd9d8<br>
    ======= Backtrace: ========= <br>
    /lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7ffff77f97e5]<br>
    /lib/x86_64-linux-gnu/libc.so.6(+0x7fe0a)[0x7ffff7801e0a]<br>
    /lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7ffff780598c]<br>
    /home/test/RT-Test/InMul[0x400b98]<br>
    /lib/x86_64-linux-gnu/librtgc.so(rtalloc_start_thread+0x1ef)[0x7ffff7b4fa2c]
    /lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7ffff756c6ba]
    /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7ffff788882d]</p>
  </blockquote>
  
  <p><br>I am freeing the head only once. Why am I facing this issue?<br>0x00007fffe3465010 is the address of the head. </p>