Aaron Watry <awa...@gmail.com> writes:

> I guess I misunderstood that obj() call (my IDE is misbehaving on the
> machine I was doing that work on which limited my ability to easily
> find function definitions outside of the current file).  C++ is pretty
> unfamiliar to me and I guess that I figured that the obj() was some
> alternative typecasting operation related to the typing for ctx not an
> actual function call).  This'll teach me to stay away from C++ for a
> while (again).
>

I see.  Maybe something like the attached patch will help avoid future
misunderstandings?

> The segfault that I was actually encountering ended up being in
> ocl-icd (version in the Ubuntu saucy repo).  When I built that project
> straight from git, the segfault went away (there's been quite a few
> null deref fixes in there since the version that Ubuntu 13.10
> packages).  This was after I had already gone through the memory.cpp
> code and broken my understanding of what it was doing.
>
> FYI: I was attempting to run the create-buffer piglit CL API tests
> (I'm working on a new extension of that for clCreateSubBuffer
> testing).  It was disconcerting that the cl-api-create-buffer program
> segfaulted reliably when encountering the test that attempts to
> clCreateBuffer using a NULL context (line 264 in create-buffer.c).
>
> Sorry for the noise.
>
> --Aaron
>
> On Thu, Apr 3, 2014 at 6:54 PM, Francisco Jerez <curroje...@riseup.net> wrote:
>> Aaron Watry <awa...@gmail.com> writes:
>>
>>> This should fix a segfault in the case that you're not using ocl-icd.
>>>
>>> If you're using ocl-icd, make sure your version is new enough or you'll get
>>> the segfault before you even get to clover.
>>>
>>> The null de-ref seems to have been introduced in 10.1, but earlier versions
>>> have have also been affected in other ways.
>>>
>>
>> NAK.  The obj() function already checks if the pointer is NULL.  Not
>> sure how you're getting a segfault.
>>
>>> CC: "10.1" <mesa-sta...@lists.freedesktop.org>
>>>
>>> Signed-off-by: Aaron Watry <awa...@gmail.com>
>>> ---
>>>  src/gallium/state_trackers/clover/api/memory.cpp | 3 +++
>>>  1 file changed, 3 insertions(+)
>>>
>>> diff --git a/src/gallium/state_trackers/clover/api/memory.cpp 
>>> b/src/gallium/state_trackers/clover/api/memory.cpp
>>> index 7ed2191..dad5ad3 100644
>>> --- a/src/gallium/state_trackers/clover/api/memory.cpp
>>> +++ b/src/gallium/state_trackers/clover/api/memory.cpp
>>> @@ -32,6 +32,9 @@ clCreateBuffer(cl_context d_ctx, cl_mem_flags flags, 
>>> size_t size,
>>>                 void *host_ptr, cl_int *r_errcode) try {
>>>     auto &ctx = obj(d_ctx);
>>>
>>> +   if (d_ctx == NULL)
>>> +        throw error(CL_INVALID_CONTEXT);
>>> +
>>>     if (bool(host_ptr) != bool(flags & (CL_MEM_USE_HOST_PTR |
>>>                                         CL_MEM_COPY_HOST_PTR)))
>>>        throw error(CL_INVALID_HOST_PTR);
>>> --
>>> 1.8.3.2
>>>
>>> _______________________________________________
>>> mesa-stable mailing list
>>> mesa-sta...@lists.freedesktop.org
>>> http://lists.freedesktop.org/mailman/listinfo/mesa-stable

From 68f3b62a6eb6edb5a0b757916ac2480aa0e15fda Mon Sep 17 00:00:00 2001
From: Francisco Jerez <curroje...@riseup.net>
Date: Fri, 4 Apr 2014 14:06:11 +0200
Subject: [PATCH] clover: Document that the *obj*() helpers already take care
 of object validation.

---
 src/gallium/state_trackers/clover/core/object.hpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/gallium/state_trackers/clover/core/object.hpp b/src/gallium/state_trackers/clover/core/object.hpp
index b8b3da8..697565c 100644
--- a/src/gallium/state_trackers/clover/core/object.hpp
+++ b/src/gallium/state_trackers/clover/core/object.hpp
@@ -113,7 +113,8 @@ namespace clover {
    }
 
    ///
-   /// Get a Clover object from an API object.
+   /// Get a Clover object from an API object performing object
+   /// validation.
    ///
    /// \a T can either be the Clover object type to return or a \a tag
    /// object to select some special validation behavior by means of a
@@ -131,8 +132,8 @@ namespace clover {
    }
 
    ///
-   /// Get a pointer to a Clover object from an API object. Returns
-   /// \c NULL if its argument is \c NULL.
+   /// Get a pointer to a Clover object from an API object performing
+   /// object validation.  Returns \c NULL if its argument is \c NULL.
    ///
    /// \sa obj
    ///
@@ -165,7 +166,8 @@ namespace clover {
    }
 
    ///
-   /// Get a range of Clover objects from a range of API objects.
+   /// Get a range of Clover objects from a range of API objects
+   /// performing object validation.
    ///
    /// \sa obj
    ///
-- 
1.9.1

Attachment: pgp0lMMF1OxcM.pgp
Description: PGP signature

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to