On Mon, Nov 30, 2015 at 11:55:20PM +0300, Ilya Verbin wrote: > Ok, but it doesn't solve the issue with doing it for the executable, because > gomp_unmap_tgt (n->tgt) will want to run free_func on uninitialized device.
?? You mean that the devicep->unload_image_func (devicep->target_id, version, target_data); call deinitializes the device or something else (I mean, if there is some other tgt, then it had to be initialized)? If it is just that order, I wonder if you can't just move the unload_image_func call after the splay_tree_remove loops (or even after the node freeing call). Jakub