On Tue, Oct 13, 2015 at 05:48:11PM +0300, Ilya Verbin wrote: > On Mon, Jun 15, 2015 at 22:48:50 +0300, Ilya Verbin wrote: > > @@ -950,50 +997,41 @@ GOMP_target (int device, void (*fn) (void *), const > > void *unused, > > ... > > + devicep->run_func (devicep->target_id, fn_addr, (void *) > > tgt_vars->tgt_start); > > If mapnum is 0, tgt_vars->tgt_start is uninitialized. This is not a big bug, > because in this case the target function doesn't use this pointer, however > valgrind warns about sending uninitialized data to target. > OK for gomp-4_1-branch? > > > libgomp/ > * target.c (gomp_map_vars): Zero tgt->tgt_start when mapnum is 0.
gomp-4_1-branch is frozen. I'd prefer to initialize tgt_start and tgt_end to 0 just in the if (mapnum == 0) return tgt; case. With that change it is ok for trunk. > diff --git a/libgomp/target.c b/libgomp/target.c > index 95360d1..c4e3323 100644 > --- a/libgomp/target.c > +++ b/libgomp/target.c > @@ -323,6 +323,7 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t > mapnum, > struct splay_tree_key_s cur_node; > struct target_mem_desc *tgt > = gomp_malloc (sizeof (*tgt) + sizeof (tgt->list[0]) * mapnum); > + tgt->tgt_start = 0; > tgt->list_count = mapnum; > tgt->refcount = pragma_kind == GOMP_MAP_VARS_ENTER_DATA ? 0 : 1; > tgt->device_descr = devicep; Jakub