Initial bug report:
http://lists.blender.org/pipermail/bf-committers/2010-May/027569.html
The BLI_thread_is_main function does not work properly on 64-bit Windows
Vista (together with the code compiled using VC++ 2008 and CMake). The
problem is that the function uses memcmp() to check if two threads are
the same. The pthread_t type on this specific platform is defined in
lib\win64\pthreads\include\pthread.h as follows:
typedef struct {
void * p;
unsigned int x;
} ptw32_handle_t;
typedef ptw32_handle_t pthread_t;
A subtle fact is that sizeof(void *) + sizeof(unsigned int) == 12, whereas
sizeof(pthread_t) == 16. This means that the thread identity test using
memcmp in the following way results in a comparison of 4 uninitialized
bytes:
return !memcmp(&tid, &mainid, sizeof(pthread_t));
In the tested platform, this identity check fails even when the two threads
are the same. Apparently using pthread_equal() looks a proper solution:
return pthread_equal(tid, mainid);
This latter thread identity test works fine in the tested platform, allowing
GPU_free_unused_buffers() to release the queued images properly.
If for some reason the use of pthread_equal() has been avoided on some
other platforms, conditional compilation for enabling a platform-specific
BLI_thread_is_main implementation would be necessary.
Description
Description