title: memcpy() creates segmentation fault after too many iterations
body: <p>I am trying to create a multithreading library in c. Here is the <a href="https://github.com/mjrusty/multithreading-example" rel="nofollow noreferrer">link to whole project</a> (because pasting the code here would be too much text).</p>
  <p>In the file <code>tests/MultithreadingTests.c</code> I am testing to the functionality of <code>lib/systems/multithreading/src/ThreadPool.c</code>. The function <code>add_work</code> adds any routine function the the work queue which utilises the functionality of <code>lib/sds/lists/src/Queue.c</code> and <code>lib/sds/lists/src/LinkedList.c</code>. In <code>MultithreadingTests.c</code>, <code>NUM_TESTS</code> defines the number of jobs I am adding to the work queue to be performed by <code>NUM_THREADS</code></p>
  <p>I am facing a weird issue with the code. If <code>NUM_TESTS</code> any number is less than <code>349,261</code>, the code works perfectly fine but any number higher than or equal to <code>349,261</code> results in segmentation fault. I tried to check where exactly the segmentation fault is happening and found that it happens in the <code>lib/sds/lists/src/Node.c</code> at line number 29 at <code>memcpy(node-&gt;data, data, size);</code></p>
  <p>The flow of code for the error is</p>
  <ul>
  <li><code>tests/MultiThreadingTests.c</code> line 95 at <code>pool-&gt;add_work(pool, new_thread_job(routine, &amp;arguments[i]));</code></li>
  <li><code>lib/systems/multithreading/src/ThreadPool.c</code> line 150 <code>thread_pool-&gt;work.push(&amp;thread_pool-&gt;work, &amp;job, sizeof(job));</code></li>
  <li><code>lib/sds/lists/src/Queue.c</code> line 54 <code>return q-&gt;list.insert(&amp;q-&gt;list, q-&gt;list.length, data, size);</code></li>
  <li><code>lib/sds/lists/src/LinkedLists.c</code> line 107 <code>Node *node_to_insert = new_node(data, size);</code></li>
  <li><code>lib/sds/lists/src/Node.c</code> line 29 <code>memcpy(node-&gt;data, data, size);</code></li>
  </ul>
  <p>I am not sure why this issue is happening only when the number of jobs is higher than or equal to 349,261 but not when its smaller.</p>