1
1

This commit fixes pointer arithmetic done with void * pointers in memheap. This commit closes trac:3844

This commit was SVN r29520.

The following Trac tickets were found above:
  Ticket 3844 --> https://svn.open-mpi.org/trac/ompi/ticket/3844
Этот коммит содержится в:
Joshua Ladd 2013-10-25 15:27:50 +00:00
родитель 9cea216c0e
Коммит 6b4bfcf4d7
4 изменённых файлов: 14 добавлений и 12 удалений

Просмотреть файл

@ -245,7 +245,7 @@ static int __shm_attach(map_segment_t *s, size_t size, int use_hp, int do_rmid)
s->shmid = shmid;
s->start = addr;
s->size = size;
s->end = s->start + s->size;
s->end = (void *) (((unsigned char *)s->start) + s->size);
s->context = &shm_context;
return OSHMEM_SUCCESS;
@ -297,7 +297,7 @@ MAP_ANONYMOUS |
s->shmid = MEMHEAP_SHM_INVALID;
s->start = addr;
s->size = size;
s->end = s->start + s->size;
s->end = (void *) (((unsigned char *)s->start) + s->size);
s->context = NULL;
return OSHMEM_SUCCESS;

Просмотреть файл

@ -528,8 +528,8 @@ static inline void* va2rva(void* va,
void* local_base,
void* remote_base)
{
return (void*) (remote_base > local_base ? (uintptr_t)va + (remote_base - local_base) :
(uintptr_t)va - (local_base - remote_base));
return (void*) (remote_base > local_base ? (uintptr_t)va + (((uintptr_t)remote_base) - ((uintptr_t)local_base)) :
(uintptr_t)va - (((uintptr_t)remote_base) - ((uintptr_t)local_base)));
}
mca_spml_mkey_t * mca_memheap_base_get_cached_mkey(int pe,
@ -599,7 +599,8 @@ uint64_t mca_memheap_base_find_offset(int pe,
s = __find_va(va);
return ((s && s->is_active) ? (rva - s->mkeys_cache[pe][tr_id].va_base) : 0);
return ((s && s->is_active) ?
(uint64_t) ((uintptr_t)rva - (uintptr_t)s->mkeys_cache[pe][tr_id].va_base) : 0);
}
int mca_memheap_base_is_symmetric_addr(const void* va)
@ -618,10 +619,11 @@ int mca_memheap_base_detect_addr_type(void* va)
if (s->type == MAP_SEGMENT_STATIC) {
addr_type = ADDR_STATIC;
} else if ((uintptr_t)va >= (uintptr_t) s->start
&& (uintptr_t)va < (uintptr_t) (s->start + mca_memheap.memheap_size)) {
&& (uintptr_t)va < (uintptr_t) (((size_t)s->start) + mca_memheap.memheap_size)) {
addr_type = ADDR_USER;
} else {
assert( (uintptr_t)va >= (uintptr_t)(s->start + mca_memheap.memheap_size) && (uintptr_t)va < (uintptr_t)s->end);
assert( (uintptr_t)va >= (uintptr_t)(((size_t)s->start) + mca_memheap.memheap_size)
&& (uintptr_t)va < (uintptr_t)s->end);
addr_type = ADDR_PRIVATE;
}
}

Просмотреть файл

@ -31,7 +31,7 @@ int mca_memheap_base_reg(mca_memheap_map_t *memheap_map)
i,
s->start,
s->end,
(long long)(s->end - s->start),
(long long)(((uintptr_t)s->end) - ((uintptr_t)s->start)),
s->type,
s->shmid);
ret = __reg_segment(s, &memheap_map->num_transports);
@ -56,7 +56,7 @@ int mca_memheap_base_dereg(mca_memheap_map_t *memheap_map)
i,
s->start,
s->end,
(long long)(s->end - s->start));
(long long)(((uintptr_t)s->end) - ((uintptr_t)s->start))),
ret = __dereg_segment(s);
}
@ -110,7 +110,7 @@ static int __reg_segment(map_segment_t *s, int *num_btl)
if (!rc) {
s->mkeys = MCA_SPML_CALL(register((void *)(unsigned long)s->start,
s->end - s->start,
(long long)((uintptr_t)s->end) - ((uintptr_t)s->start),
MEMHEAP_SHM_CODE(s->type, s->shmid),
num_btl));
if (NULL == s->mkeys) {

Просмотреть файл

@ -62,12 +62,12 @@ int mca_memheap_base_static_init(mca_memheap_map_t *map)
s->shmid = MEMHEAP_SHM_INVALID;
s->start = memheap_context.mem_segs[i].start;
s->end = memheap_context.mem_segs[i].end;
s->size = s->end - s->start;
s->size = (size_t) (((uintptr_t)s->end) - ((uintptr_t)s->start));
s->type = MAP_SEGMENT_STATIC;
s->context = NULL;
map->n_segments++;
total_mem += s->end - s->start;
total_mem += (size_t) (((uintptr_t)s->end) - ((uintptr_t)s->start));
}
MEMHEAP_VERBOSE(1,
"Memheap static memory: %llu byte(s), %d segments",