Browse Source

src/datawizard/memalloc: store interface size of the memchunk as the handle may no longer be valid when reusing the memchunk (thanks to Cyril Bordage for reporting the bug)

Nathalie Furmento 12 years ago
parent
commit
402e568b27
2 changed files with 4 additions and 2 deletions
  1. 2 1
      src/datawizard/memalloc.c
  2. 2 1
      src/datawizard/memalloc.h

+ 2 - 1
src/datawizard/memalloc.c

@@ -427,7 +427,7 @@ static void reuse_mem_chunk(unsigned node, struct _starpu_data_replicate *new_re
 
 
 	STARPU_ASSERT(new_replicate->data_interface);
 	STARPU_ASSERT(new_replicate->data_interface);
 	STARPU_ASSERT(mc->chunk_interface);
 	STARPU_ASSERT(mc->chunk_interface);
-	memcpy(new_replicate->data_interface, mc->chunk_interface, old_replicate->handle->ops->interface_size);
+	memcpy(new_replicate->data_interface, mc->chunk_interface, mc->size_interface);
 
 
 	mc->data = new_replicate->handle;
 	mc->data = new_replicate->handle;
 	/* mc->ops, mc->footprint and mc->interface should be
 	/* mc->ops, mc->footprint and mc->interface should be
@@ -721,6 +721,7 @@ static struct _starpu_mem_chunk *_starpu_memchunk_init(struct _starpu_data_repli
 
 
 	/* Save a copy of the interface */
 	/* Save a copy of the interface */
 	mc->chunk_interface = malloc(interface_size);
 	mc->chunk_interface = malloc(interface_size);
+	mc->size_interface = interface_size;
 	STARPU_ASSERT(mc->chunk_interface);
 	STARPU_ASSERT(mc->chunk_interface);
 	memcpy(mc->chunk_interface, replicate->data_interface, interface_size);
 	memcpy(mc->chunk_interface, replicate->data_interface, interface_size);
 
 

+ 2 - 1
src/datawizard/memalloc.h

@@ -41,9 +41,10 @@ LIST_TYPE(_starpu_mem_chunk,
 	 */
 	 */
 	struct starpu_data_interface_ops *ops;
 	struct starpu_data_interface_ops *ops;
 	void *chunk_interface;
 	void *chunk_interface;
+	size_t size_interface;
 	unsigned automatically_allocated;
 	unsigned automatically_allocated;
 
 
-	/* the size is only set when calling _starpu_request_mem_chunk_removal(),
+	/* the size of the data is only set when calling _starpu_request_mem_chunk_removal(),
          * it is needed by free_memory_on_node() which is called when
          * it is needed by free_memory_on_node() which is called when
          * the handle is no longer valid. It should not be used otherwise.
          * the handle is no longer valid. It should not be used otherwise.
 	 */
 	 */