[Beignet] [PATCH] Fix a negative number alignment bug in RegisterFilePartitioner allocate.
Zhigang Gong
zhigang.gong at linux.intel.com
Thu May 16 22:05:12 PDT 2013
LGTM. Thanks.
BTW, do you have a simple test case in hand to trigger this bug?
If so, you are encourgaged to submit the unit test case also.
On Tue, May 14, 2013 at 10:39:12AM +0800, Yang Rong wrote:
>
> Signed-off-by: Yang Rong <rong.r.yang at intel.com>
> ---
> backend/src/backend/context.cpp | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/backend/src/backend/context.cpp b/backend/src/backend/context.cpp
> index c636b48..0beea1d 100644
> --- a/backend/src/backend/context.cpp
> +++ b/backend/src/backend/context.cpp
> @@ -120,7 +120,12 @@ namespace gbe
> continue;
> }
> } else {
> - aligned = ALIGN(list->offset+list->size-size-(alignment-1), alignment); //alloc from block's tail
> + int16_t unaligned = list->offset + list->size - size - (alignment-1);
> + if(unaligned < 0) {
> + list = list->prev;
> + continue;
> + }
> + aligned = ALIGN(unaligned, alignment); //alloc from block's tail
> spaceOnLeft = aligned - list->offset;
> spaceOnRight = list->size - size - spaceOnLeft;
>
> @@ -196,7 +201,6 @@ namespace gbe
>
> // Track the allocation to retrieve the size later
> allocatedBlocks.insert(std::make_pair(aligned, size));
> -
> // We have a valid offset now
> return aligned;
> }
> --
> 1.7.9.5
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list