mxmo0rhuhn/ConcurrentCprogramming — pull request #2 by rethab (2014-05-21 16:16:27+00:00)
Title: make sure payload memory is thread specific

I think your problem is that you are doing the memory allocations in the concurrentlist's appendListElement function, which is invoked after the new thread is created. This means that the new thread might be very fast and use stale memory.

While this malloc in the loop makes all tests pass, it does not solve the problem entirely as there is still a malloc inside appendListElement function. I did not remove it, because there is other code that depends on that. Still, it should be removed in order to avoid allocating the memory twice.