From 45fd651d2fd3c7e2d8fcab582bbbe8056375df62 Mon Sep 17 00:00:00 2001 From: foreman Date: Thu, 9 Apr 2015 08:41:37 -0400 Subject: [PATCH] P4 to Git Change 1138941 by emankov@em-hsa-amd on 2015/04/09 08:28:04 ECR #333753 - ORCA RT: aclCompilerInit usage fix Passing pointers on CRT memory management functions to dynamically loaded library is unsafe and may lead to memory corruption. But actually the pointers aren't actually passed. They are cut off by the struct size: sizeof(aclCompilerOptions_0_8) and hence never being called. P.S. If it was aclCompilerOptions_0_8_1 the pointers would be taken into account and a heap corruption would occur. So the change intended to liquidate possible misunderstanding of malloc & free functions usage, and doesn't change the behaviour of aclCompilerInit function at all. Testing: pre check-in Reviewers: German Andreev, Stanislav Mekhanoshin Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/cpu/cpudevice.cpp#271 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#507 edit --- rocclr/runtime/device/cpu/cpudevice.cpp | 4 +--- rocclr/runtime/device/gpu/gpudevice.cpp | 12 +++--------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/rocclr/runtime/device/cpu/cpudevice.cpp b/rocclr/runtime/device/cpu/cpudevice.cpp index 6d1aa5afea..bd2e4d0af4 100644 --- a/rocclr/runtime/device/cpu/cpudevice.cpp +++ b/rocclr/runtime/device/cpu/cpudevice.cpp @@ -68,9 +68,7 @@ Device::init() NULL, NULL, NULL, - NULL, - &::malloc, - &::free + NULL }; acl_error error; compiler_ = aclCompilerInit(&opts, &error); diff --git a/rocclr/runtime/device/gpu/gpudevice.cpp b/rocclr/runtime/device/gpu/gpudevice.cpp index d23a175cf1..55f136a2db 100644 --- a/rocclr/runtime/device/gpu/gpudevice.cpp +++ b/rocclr/runtime/device/gpu/gpudevice.cpp @@ -203,9 +203,7 @@ NullDevice::create(CALtarget target) NULL, NULL, NULL, - AMD_OCL_SC_LIB, - &::malloc, - &::free + AMD_OCL_SC_LIB }; // Initialize the compiler handle acl_error error; @@ -949,9 +947,7 @@ Device::create(CALuint ordinal, CALuint numOfDevices) NULL, NULL, NULL, - AMD_OCL_SC_LIB, - &::malloc, - &::free + AMD_OCL_SC_LIB }; // Initialize the compiler handle acl_error error; @@ -1259,9 +1255,7 @@ Device::init() NULL, NULL, NULL, - AMD_OCL_SC_LIB, - &::malloc, - &::free + AMD_OCL_SC_LIB }; hsaCompiler_ = NULL;