Re: [Mesa-dev] [PATCH] st/mesa: fix sampler_view REALLOC/FREE macro mix-up

2014-04-10 Thread Jakob Bornecrantz
On Thu, Apr 10, 2014 at 3:26 AM, Brian Paul bri...@vmware.com wrote:
 We were using REALLOC() from u_memory.h but FREE() from imports.h.
 This mismatch caused us to trash the heap on Windows after we
 deleted a texture object.

 This fixes a regression from commit 6c59be7776e4d.
 ---
  src/mesa/state_tracker/st_cb_texture.c |2 +-
  src/mesa/state_tracker/st_texture.c|   12 
  src/mesa/state_tracker/st_texture.h|3 +++
  3 files changed, 16 insertions(+), 1 deletion(-)

Is this patch obsoleted by the FREE/MALLOC remove series? Otherwise
this patch is:
Reviewed-by: Jakob Bornecrantz ja...@vmware.com

Cheers, Jakob.


 diff --git a/src/mesa/state_tracker/st_cb_texture.c 
 b/src/mesa/state_tracker/st_cb_texture.c
 index 353415b..304dc91 100644
 --- a/src/mesa/state_tracker/st_cb_texture.c
 +++ b/src/mesa/state_tracker/st_cb_texture.c
 @@ -155,7 +155,7 @@ st_DeleteTextureObject(struct gl_context *ctx,

 pipe_resource_reference(stObj-pt, NULL);
 st_texture_release_all_sampler_views(stObj);
 -   FREE(stObj-sampler_views);
 +   st_texture_free_sampler_views(stObj);
 _mesa_delete_texture_object(ctx, texObj);
  }

 diff --git a/src/mesa/state_tracker/st_texture.c 
 b/src/mesa/state_tracker/st_texture.c
 index 8d559df..cfa0605 100644
 --- a/src/mesa/state_tracker/st_texture.c
 +++ b/src/mesa/state_tracker/st_texture.c
 @@ -483,3 +483,15 @@ st_texture_release_all_sampler_views(struct 
 st_texture_object *stObj)
 for (i = 0; i  stObj-num_sampler_views; ++i)
pipe_sampler_view_reference(stObj-sampler_views[i], NULL);
  }
 +
 +
 +void
 +st_texture_free_sampler_views(struct st_texture_object *stObj)
 +{
 +   /* NOTE:
 +* We use FREE() here to match REALLOC() above.  Both come from
 +* u_memory.h, not imports.h.  If we mis-match MALLOC/FREE from
 +* those two headers we can trash the heap.
 +*/
 +   FREE(stObj-sampler_views);
 +}
 diff --git a/src/mesa/state_tracker/st_texture.h 
 b/src/mesa/state_tracker/st_texture.h
 index 87de9f9..f2afaf1 100644
 --- a/src/mesa/state_tracker/st_texture.h
 +++ b/src/mesa/state_tracker/st_texture.h
 @@ -241,4 +241,7 @@ st_texture_release_sampler_view(struct st_context *st,
  extern void
  st_texture_release_all_sampler_views(struct st_texture_object *stObj);

 +void
 +st_texture_free_sampler_views(struct st_texture_object *stObj);
 +
  #endif
 --
 1.7.10.4
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] st/mesa: fix sampler_view REALLOC/FREE macro mix-up

2014-04-10 Thread Christian König

Am 10.04.2014 03:26, schrieb Brian Paul:

We were using REALLOC() from u_memory.h but FREE() from imports.h.
This mismatch caused us to trash the heap on Windows after we
deleted a texture object.

This fixes a regression from commit 6c59be7776e4d.


Reviewed-by: Christian König christian.koe...@amd.com


---
  src/mesa/state_tracker/st_cb_texture.c |2 +-
  src/mesa/state_tracker/st_texture.c|   12 
  src/mesa/state_tracker/st_texture.h|3 +++
  3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c
index 353415b..304dc91 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -155,7 +155,7 @@ st_DeleteTextureObject(struct gl_context *ctx,
  
 pipe_resource_reference(stObj-pt, NULL);

 st_texture_release_all_sampler_views(stObj);
-   FREE(stObj-sampler_views);
+   st_texture_free_sampler_views(stObj);
 _mesa_delete_texture_object(ctx, texObj);
  }
  
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c

index 8d559df..cfa0605 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -483,3 +483,15 @@ st_texture_release_all_sampler_views(struct 
st_texture_object *stObj)
 for (i = 0; i  stObj-num_sampler_views; ++i)
pipe_sampler_view_reference(stObj-sampler_views[i], NULL);
  }
+
+
+void
+st_texture_free_sampler_views(struct st_texture_object *stObj)
+{
+   /* NOTE:
+* We use FREE() here to match REALLOC() above.  Both come from
+* u_memory.h, not imports.h.  If we mis-match MALLOC/FREE from
+* those two headers we can trash the heap.
+*/
+   FREE(stObj-sampler_views);
+}
diff --git a/src/mesa/state_tracker/st_texture.h 
b/src/mesa/state_tracker/st_texture.h
index 87de9f9..f2afaf1 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -241,4 +241,7 @@ st_texture_release_sampler_view(struct st_context *st,
  extern void
  st_texture_release_all_sampler_views(struct st_texture_object *stObj);
  
+void

+st_texture_free_sampler_views(struct st_texture_object *stObj);
+
  #endif


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] st/mesa: fix sampler_view REALLOC/FREE macro mix-up

2014-04-10 Thread Jose Fonseca
To prevent this to ocurr again in the future we should be probably using 
os_malloc/os_free and friends instead of the overloaded MALLOC/FREE/etc macros.

We should probably kill MALLOC/FREE completely.

Jose

- Original Message -
 We were using REALLOC() from u_memory.h but FREE() from imports.h.
 This mismatch caused us to trash the heap on Windows after we
 deleted a texture object.
 
 This fixes a regression from commit 6c59be7776e4d.
 ---
  src/mesa/state_tracker/st_cb_texture.c |2 +-
  src/mesa/state_tracker/st_texture.c|   12 
  src/mesa/state_tracker/st_texture.h|3 +++
  3 files changed, 16 insertions(+), 1 deletion(-)
 
 diff --git a/src/mesa/state_tracker/st_cb_texture.c
 b/src/mesa/state_tracker/st_cb_texture.c
 index 353415b..304dc91 100644
 --- a/src/mesa/state_tracker/st_cb_texture.c
 +++ b/src/mesa/state_tracker/st_cb_texture.c
 @@ -155,7 +155,7 @@ st_DeleteTextureObject(struct gl_context *ctx,
  
 pipe_resource_reference(stObj-pt, NULL);
 st_texture_release_all_sampler_views(stObj);
 -   FREE(stObj-sampler_views);
 +   st_texture_free_sampler_views(stObj);
 _mesa_delete_texture_object(ctx, texObj);
  }
  
 diff --git a/src/mesa/state_tracker/st_texture.c
 b/src/mesa/state_tracker/st_texture.c
 index 8d559df..cfa0605 100644
 --- a/src/mesa/state_tracker/st_texture.c
 +++ b/src/mesa/state_tracker/st_texture.c
 @@ -483,3 +483,15 @@ st_texture_release_all_sampler_views(struct
 st_texture_object *stObj)
 for (i = 0; i  stObj-num_sampler_views; ++i)
pipe_sampler_view_reference(stObj-sampler_views[i], NULL);
  }
 +
 +
 +void
 +st_texture_free_sampler_views(struct st_texture_object *stObj)
 +{
 +   /* NOTE:
 +* We use FREE() here to match REALLOC() above.  Both come from
 +* u_memory.h, not imports.h.  If we mis-match MALLOC/FREE from
 +* those two headers we can trash the heap.
 +*/
 +   FREE(stObj-sampler_views);
 +}
 diff --git a/src/mesa/state_tracker/st_texture.h
 b/src/mesa/state_tracker/st_texture.h
 index 87de9f9..f2afaf1 100644
 --- a/src/mesa/state_tracker/st_texture.h
 +++ b/src/mesa/state_tracker/st_texture.h
 @@ -241,4 +241,7 @@ st_texture_release_sampler_view(struct st_context *st,
  extern void
  st_texture_release_all_sampler_views(struct st_texture_object *stObj);
  
 +void
 +st_texture_free_sampler_views(struct st_texture_object *stObj);
 +
  #endif
 --
 1.7.10.4
 
 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-devk=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0Ar=NMr9uy2iTjWVixC0wOcYCWEIYhfo80qKwRgdodpoDzA%3D%0Am=1olO9xu3XgincgJXOzgMZ%2F%2FOJ20%2FdB2ex7mU8kHIAi0%3D%0As=31ccb1bdd6a7109d026f0078b2a4777af1982e91714c765af6f4ab57ebb6
 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] st/mesa: fix sampler_view REALLOC/FREE macro mix-up

2014-04-10 Thread Brian Paul

On 04/10/2014 01:43 AM, Jakob Bornecrantz wrote:

On Thu, Apr 10, 2014 at 3:26 AM, Brian Paul bri...@vmware.com wrote:

We were using REALLOC() from u_memory.h but FREE() from imports.h.
This mismatch caused us to trash the heap on Windows after we
deleted a texture object.

This fixes a regression from commit 6c59be7776e4d.
---
  src/mesa/state_tracker/st_cb_texture.c |2 +-
  src/mesa/state_tracker/st_texture.c|   12 
  src/mesa/state_tracker/st_texture.h|3 +++
  3 files changed, 16 insertions(+), 1 deletion(-)


Is this patch obsoleted by the FREE/MALLOC remove series?


Not exactly.  If I try to use FREE(stObj-sampler_views) in 
st_cb_texture.c I need to include u_memory.h.  But then I get 
preprocessor warnings about MALLOC_STRUCT() and CALLOC_STRUCT() being 
redefined.  So then I need to insert some #undef MALLOC_STRUCT lines.

It's just messy.

-Brian


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] st/mesa: fix sampler_view REALLOC/FREE macro mix-up

2014-04-10 Thread Jakob Bornecrantz
On 10 Apr 2014 15:56, Brian Paul bri...@vmware.com wrote:

 On 04/10/2014 01:43 AM, Jakob Bornecrantz wrote:

 On Thu, Apr 10, 2014 at 3:26 AM, Brian Paul bri...@vmware.com wrote:

 We were using REALLOC() from u_memory.h but FREE() from imports.h.
 This mismatch caused us to trash the heap on Windows after we
 deleted a texture object.

 This fixes a regression from commit 6c59be7776e4d.
 ---
   src/mesa/state_tracker/st_cb_texture.c |2 +-
   src/mesa/state_tracker/st_texture.c|   12 
   src/mesa/state_tracker/st_texture.h|3 +++
   3 files changed, 16 insertions(+), 1 deletion(-)


 Is this patch obsoleted by the FREE/MALLOC remove series?


 Not exactly.  If I try to use FREE(stObj-sampler_views) in
st_cb_texture.c I need to include u_memory.h.  But then I get
preprocessor warnings about MALLOC_STRUCT() and CALLOC_STRUCT() being
redefined.  So then I need to insert some #undef MALLOC_STRUCT lines.
 It's just messy.

Ah fair enough.

Cheers, Jakob.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] st/mesa: fix sampler_view REALLOC/FREE macro mix-up

2014-04-09 Thread Brian Paul
We were using REALLOC() from u_memory.h but FREE() from imports.h.
This mismatch caused us to trash the heap on Windows after we
deleted a texture object.

This fixes a regression from commit 6c59be7776e4d.
---
 src/mesa/state_tracker/st_cb_texture.c |2 +-
 src/mesa/state_tracker/st_texture.c|   12 
 src/mesa/state_tracker/st_texture.h|3 +++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c
index 353415b..304dc91 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -155,7 +155,7 @@ st_DeleteTextureObject(struct gl_context *ctx,
 
pipe_resource_reference(stObj-pt, NULL);
st_texture_release_all_sampler_views(stObj);
-   FREE(stObj-sampler_views);
+   st_texture_free_sampler_views(stObj);
_mesa_delete_texture_object(ctx, texObj);
 }
 
diff --git a/src/mesa/state_tracker/st_texture.c 
b/src/mesa/state_tracker/st_texture.c
index 8d559df..cfa0605 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -483,3 +483,15 @@ st_texture_release_all_sampler_views(struct 
st_texture_object *stObj)
for (i = 0; i  stObj-num_sampler_views; ++i)
   pipe_sampler_view_reference(stObj-sampler_views[i], NULL);
 }
+
+
+void
+st_texture_free_sampler_views(struct st_texture_object *stObj)
+{
+   /* NOTE:
+* We use FREE() here to match REALLOC() above.  Both come from
+* u_memory.h, not imports.h.  If we mis-match MALLOC/FREE from
+* those two headers we can trash the heap.
+*/
+   FREE(stObj-sampler_views);
+}
diff --git a/src/mesa/state_tracker/st_texture.h 
b/src/mesa/state_tracker/st_texture.h
index 87de9f9..f2afaf1 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -241,4 +241,7 @@ st_texture_release_sampler_view(struct st_context *st,
 extern void
 st_texture_release_all_sampler_views(struct st_texture_object *stObj);
 
+void
+st_texture_free_sampler_views(struct st_texture_object *stObj);
+
 #endif
-- 
1.7.10.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev