[Beignet] [PATCH] Avoid possible invalid pointer by vector interator.
Song, Ruiling
ruiling.song at intel.com
Wed Dec 28 08:32:57 UTC 2016
Looks good. Thanks for the fix.
- Ruiling
> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> yan.wang at linux.intel.com
> Sent: Wednesday, December 28, 2016 4:28 PM
> To: beignet at lists.freedesktop.org
> Cc: Yan Wang <yan.wang at linux.intel.com>
> Subject: [Beignet] [PATCH] Avoid possible invalid pointer by vector interator.
>
> From: Yan Wang <yan.wang at linux.intel.com>
>
> "revisit" as vector containber will be pushed more elements in
> findPointerEsacape() and cause previous interator to introduce
> possible invalid pointer.
> When compiling huge kernel like blender, it will cause random
> segment fault crash.
> [] operator will be more safe.
>
> Signed-off-by: Yan Wang <yan.wang at linux.intel.com>
> ---
> backend/src/llvm/llvm_gen_backend.cpp | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/backend/src/llvm/llvm_gen_backend.cpp
> b/backend/src/llvm/llvm_gen_backend.cpp
> index 8c7a230..e3543ae 100644
> --- a/backend/src/llvm/llvm_gen_backend.cpp
> +++ b/backend/src/llvm/llvm_gen_backend.cpp
> @@ -1437,8 +1437,8 @@ namespace gbe
> }
> }
> // storing/loading pointer would introduce revisit
> - for (std::vector<Value *>::iterator iter = revisit.begin(); iter != revisit.end();
> ++iter) {
> - findPointerEscape(*iter, mixedPtr, true, revisit);
> + for (size_t i = 0; i < revisit.size(); ++i) {
> + findPointerEscape(revisit[i], mixedPtr, true, revisit);
> }
>
> // the second pass starts from mixed pointer
> --
> 2.7.4
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list