Batched shading crashes in `pointcloud_search()`
johnhaddon opened this issue · comments
Problem
Expected behavior: pointcloud_search()
returns the same result in batched shading mode as in regular mode.
Actual behavior: pointcloud_search()
crashes in batched shading mode with the following stack trace :
#0 0x00007fff312a32de in OSL_v1_12::b16_AVX512_noFMA_pvt::(anonymous namespace)::default_pointcloud_search(OSL_v1_12::BatchedShaderGlobals<16>*, OpenImageIO_v2_4::ustring, void const*, OSL_v1_12::Wide<float const, 16>, int, bool, OSL_v1_12::BatchedRendererServices<16>::PointCloudSearchResults&)::{lambda(OSL_v1_12::ActiveLane)#1}::operator()(OSL_v1_12::ActiveLane) const () from /home/john/dev/build/gaffer-1.3/lib/lib_b16_AVX512_noFMA_oslexec.so
#1 0x00007fff312a947f in osl_b16_AVX512_noFMA_pointcloud_search_masked () from /home/john/dev/build/gaffer-1.3/lib/lib_b16_AVX512_noFMA_oslexec.so
#2 0x00007fffd58002ad in ?? ()
#3 0x0000000000000001 in ?? ()
#4 0x0000000000000000 in ?? ()
Steps to Reproduce
- Build OSL with the default Partio-based pointcloud services (I used Partio 1.14.6).
- Write a shader that uses
pointcloud_search()
and run it in batched mode.
(These repro steps are a bit lame - I can probably come up with something more specific if the bug doesn't immediately jump out at you).
Versions
- OSL branch/version: 1.12.9
- OS: CentOS 7
- C++ compiler: GCC 9.3.1
- LLVM version: 11.1.0
- OIIO version: 2.4.11.0
Did a bit more digging. The crash only occurs when not providing the "index"
output array which the language docs imply is optional (and which can be omitted fine in non-batched mode), but which BatchedRendererServices claims is mandatory. The crash then occurs when writing via an invalid pointer in default_pointcloud_search()
.
So this is OK :
point points[5];
int indices[5];
pointcloud_search( filename, pW, 100, 5, 1, "position", points, "index", indices );
But this crashes :
point points[5];
pointcloud_search( filename, pW, 100, 5, 1, "position", points );
@AlexMWells Can you take a look at this?
I added an additional unit test and can confirm it does indeed crash:
#### Error: this command failed:
2/2 Test #999: pointcloud.batched.opt ...........***Failed 3.47 sec
/bin/sh: line 1: 138828 Aborted (core dumped) testshade --center --vary_pdxdy -g 256 256 -t 1 -param radius 0.1 -od uint8 -o Cout out_rdcloud_varying_no_index.tif rdcloud_varying_no_index >> out.txt 2>> out.txt
I'll look at the implementation...
I created
#1753
to address the crash