Skip to content
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/cmake/testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ macro (osl_add_all_tests)
printf-reg
printf-whole-array
raytype raytype-reg raytype-specialized regex-reg
reparam reparam-arrays reparam-string testoptix-reparam
reparam reparam-arrays reparam-connected-crash reparam-string testoptix-reparam
render-background render-bumptest
render-bunny
render-cornell
Expand Down
3 changes: 2 additions & 1 deletion src/liboslexec/backendllvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ BackendLLVM::getLLVMSymbolBase(const Symbol& sym)
llvm_type(sym.typespec().elementtype()));
return result;
}
if (sym.symtype() == SymTypeParam && sym.interactive()) {
if (sym.symtype() == SymTypeParam && sym.interactive()
&& !sym.connected()) {
// Special case for interactively-edited parameters -- they live in
// the interactive data block for the group.
// Generate the pointer to this symbol by offsetting into the
Expand Down
3 changes: 2 additions & 1 deletion src/liboslexec/batched_backendllvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@ BatchedBackendLLVM::getLLVMSymbolBase(const Symbol& sym)
return result;
}

if (sym.symtype() == SymTypeParam && sym.interactive()) {
if (sym.symtype() == SymTypeParam && sym.interactive()
&& !sym.connected()) {
// Special case for interactively-edited parameters -- they live in
// the interactive data block for the group.
// Generate the pointer to this symbol by offsetting into the
Expand Down
Empty file.
11 changes: 11 additions & 0 deletions testsuite/reparam-connected-crash/downstream.osl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage

// Downstream layer: 'in' will be marked interactive with an instance value
// via testshade -param:interactive=1
shader downstream(float in = 0, output float result = 0)
{
printf("in = %g\n", in);
result = in;
}
5 changes: 5 additions & 0 deletions testsuite/reparam-connected-crash/ref/out.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Compiled downstream.osl -> downstream.oso
Compiled upstream.osl -> upstream.oso
Connect upstream_layer.out to downstream_layer.in
in = 0.5

23 changes: 23 additions & 0 deletions testsuite/reparam-connected-crash/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python

# Copyright Contributors to the Open Shading Language project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage

# Regression test: downstream input param is both connected (from upstream) and
# marked interactive with an instance value.
#
# Bug: OSL give precedence to the interactive trait instead of connected. This
# leads to an attempted write of the interactive buffer. However, the offset
# is calculated incorrectly and the write occurs at interactive_buffer[-1].
#
# Correct output: in = 0.5 (u at the default shade point, from the connection)
# Buggy output: in = <garbage> (corrupted memory) or crash

command += testshade(
"-layer upstream_layer upstream "
"-layer downstream_layer -param:interactive=1 in 9.0 downstream "
"-connect upstream_layer out downstream_layer in "
)

outputs = ["out.txt"]
8 changes: 8 additions & 0 deletions testsuite/reparam-connected-crash/upstream.osl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage

shader upstream(output float out = 0)
{
out = u; // don't constant-fold
}
Loading