[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28598] trunk/blender/source/blender/gpu/ intern/gpu_draw.c: Fix for GPU_free_unused_buffers deadlock, solution by Tamito Kajiyama, thanks!
Tamito KAJIYAMA
rd6t-kjym at asahi-net.or.jp
Sat May 15 02:20:55 CEST 2010
Hi Brecht,
Thank you for fixing the deadlock issue in GPU_free_unused_buffers().
I have identified a related issue that the BLI_thread_is_main function
seems not to 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.
Hope this helps,
--
KAJIYAMA, Tamito <rd6t-kjym at asahi-net.or.jp>
----- Original Message -----
From: "Brecht Van Lommel" <brecht at blender.org>
To: <bf-blender-cvs at blender.org>
Sent: Wednesday, May 05, 2010 6:14 PM
Subject: [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28598] trunk/blender/source/blender/gpu/ intern/gpu_draw.c: Fix for
GPU_free_unused_buffers deadlock, solution by Tamito Kajiyama, thanks!
> Revision: 28598
> http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28598
> Author: blendix
> Date: 2010-05-05 19:14:43 +0200 (Wed, 05 May 2010)
>
> Log Message:
> -----------
> Fix for GPU_free_unused_buffers deadlock, solution by Tamito Kajiyama, thanks!
>
> Modified Paths:
> --------------
> trunk/blender/source/blender/gpu/intern/gpu_draw.c
>
> Modified: trunk/blender/source/blender/gpu/intern/gpu_draw.c
> ===================================================================
> --- trunk/blender/source/blender/gpu/intern/gpu_draw.c 2010-05-05 17:07:55 UTC (rev 28597)
> +++ trunk/blender/source/blender/gpu/intern/gpu_draw.c 2010-05-05 17:14:43 UTC (rev 28598)
> @@ -799,6 +799,9 @@
> {
> Image *ima;
>
> + if(!BLI_thread_is_main())
> + return;
> +
> BLI_lock_thread(LOCK_OPENGL);
>
> for(ima=image_free_queue.first; ima; ima=ima->id.next)
More information about the Bf-committers
mailing list