Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an invalid memory access on GPU while trying to access to the attribute TypeDesc in osl_get_attribute #1404

Merged
merged 1 commit into from Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/liboslexec/builtindecl.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ DECL (osl_range_check, "iiiXXXiXiXX")
DECL (osl_range_check_err, "iiiXXXiXiXX")
DECL (osl_naninf_check, "xiXiXXiXiiX")
DECL (osl_uninit_check, "xLXXXiXiXXiXiXii")
DECL (osl_get_attribute, "iXiXXiiXX")
DECL (osl_get_attribute, "iXiXXiiLX")
DECL (osl_bind_interpolated_param, "iXXLiXiXiXi")
DECL (osl_get_texture_options, "XX");
DECL (osl_get_noise_options, "XX");
Expand Down
4 changes: 2 additions & 2 deletions src/liboslexec/llvm_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2976,7 +2976,7 @@ LLVMGEN (llvm_gen_getattribute)
// We'll pass the destination's attribute type directly to the
// RenderServices callback so that the renderer can perform any
// necessary conversions from its internal format to OSL's.
const TypeDesc* dest_type = &Destination.typespec().simpletype();
TypeDesc dest_type = Destination.typespec().simpletype();

llvm::Value * args[] = {
rop.sg_void_ptr(),
Expand All @@ -2985,7 +2985,7 @@ LLVMGEN (llvm_gen_getattribute)
rop.llvm_load_value (Attribute),
rop.ll.constant ((int)array_lookup),
rop.llvm_load_value (Index),
rop.ll.constant_ptr ((void *) dest_type),
rop.ll.constant (dest_type),
rop.llvm_void_ptr (Destination),
};
llvm::Value *r = rop.ll.call_function ("osl_get_attribute", args);
Expand Down
4 changes: 2 additions & 2 deletions src/liboslexec/shadingsys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4189,7 +4189,7 @@ OSL_SHADEOP int osl_get_attribute(void *sg_,
void *attr_name_,
int array_lookup,
int index,
const void *attr_type,
long long attr_type,
void *attr_dest)
{
ShaderGlobals *sg = (ShaderGlobals *)sg_;
Expand All @@ -4199,7 +4199,7 @@ OSL_SHADEOP int osl_get_attribute(void *sg_,
return sg->context->osl_get_attribute (sg, sg->objdata,
dest_derivs, obj_name, attr_name,
array_lookup, index,
*(const TypeDesc *)attr_type,
TYPEDESC(attr_type),
attr_dest);
}

Expand Down