[Mesa-dev] [PATCH 2/2] clover: check clEnqueueMap* for map errors

Francisco Jerez currojerez at riseup.net
Tue Jun 9 14:04:38 PDT 2015


Grigori Goronzy <greg at chown.ath.cx> writes:

> Mapping can fail, and this should be handled. Return the proper error
> code and abort the associated event in this case.
> ---
>  src/gallium/state_trackers/clover/api/transfer.cpp | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/state_trackers/clover/api/transfer.cpp b/src/gallium/state_trackers/clover/api/transfer.cpp
> index 4986f53..275059c 100644
> --- a/src/gallium/state_trackers/clover/api/transfer.cpp
> +++ b/src/gallium/state_trackers/clover/api/transfer.cpp
> @@ -699,11 +699,17 @@ clEnqueueMapBuffer(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
>        map_resource_op(q, &mem, flags, blocking, obj_origin, region, &map));
>  
>     ret_object(rd_ev, hev);
> -   ret_error(r_errcode, CL_SUCCESS);
>  
>     if (blocking)
>        hev().wait();
>  
> +   if (!map) {

add_map() shouldn't ever return NULL, it just throws a
CL_OUT_OF_RESOURCES error, so this situation was already being handled
mostly.  We were returning a valid although somewhat unspecific error
code.  You could either translate CL_OUT_OF_RESOURCES to CL_MAP_FAILURE
in the catch block below or (probably better but a bit more work) make
mapping::mapping() throw CL_MAP_FAILURE directly (which is the most
specific of the two error codes) and translate it to CL_OUT_OF_RESOURCES
in the catch blocks of all API entry points of this file that use
soft_copy_op().

Thanks!

> +      hev().abort(CL_MAP_FAILURE);
> +      ret_error(r_errcode, CL_MAP_FAILURE);
> +      return NULL;
> +   }
> +
> +   ret_error(r_errcode, CL_SUCCESS);
>     return map;
>  
>  } catch (error &e) {
> @@ -734,11 +740,17 @@ clEnqueueMapImage(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
>        map_resource_op(q, &img, flags, blocking, origin, region, &map));
>  
>     ret_object(rd_ev, hev);
> -   ret_error(r_errcode, CL_SUCCESS);
>  
>     if (blocking)
>        hev().wait();
>  
> +   if (!map) {
> +      hev().abort(CL_MAP_FAILURE);
> +      ret_error(r_errcode, CL_MAP_FAILURE);
> +      return NULL;
> +   }
> +
> +   ret_error(r_errcode, CL_SUCCESS);
>     return map;
>  
>  } catch (error &e) {
> -- 
> 1.9.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150610/7092f0f8/attachment.sig>


More information about the mesa-dev mailing list