Hi, Simon. Sorry for the long delay in answering this old message, somehow it
slipped through the cracks. (Mid August -- could have been lost in the SIGGRAPH
or post-SIGGRAPH shuffle.)
The code in question looks like it handles this case:
coord = coord - origin;
coord = coord % (width-1); // <--- yes, mod by 0 when width = 1
coord += blend (simd::int4(origin), width+origin, coord < 0); // Fix
negative values
coord = blend (coord, origin, width <= 2); // <-- but replaces the bad
case with good value
coord_ = coord;
Are you saying that it crashes on the % itself? Maybe for some compilers or CPU
states it's having an exception.
But now I see, I thought that simd::int4 % would be safe, but in fact there is
no SSE mod, it's still implemented in terms of scalar ops, so if it's running
on a compiler or with CPU state that would make an exception for
divide-by-zero, that would happen unabated.
I have a proposed fix: https://github.com/OpenImageIO/oiio/pull/2121
> On Aug 21, 2017, at 5:48 AM, Simon Smith <[email protected]> wrote:
>
> Hi,
>
> I’ve got an interesting crash here that I can see *why* it occurs in the OIIO
> codebase, but is it down to misuse or a corner-case crash?
>
> So, I’m using the texture system sampling via the texture(…) call.
> The image is mipmapped, and the level it’s decided to sample from is mipmap
> level 9 (the highest) so presents a ImageSpec with a width/height of 1 pixel.
>
> Sampling options are set to Smart Periodic, and within this is calls down to
> sample_bicubic (because of the near-side-on view of the texture applied to a
> flat quad - the derivatives are 34.0/0.1 and 66.4/0.2).
> Down here the code then goes into the SIMD implementation of periodic shared
> border (wrap_periodic_sharedborder_simd call)
>
> Now, because the width passed in is 1, the modulus operator is given a value
> of 0, and hence the crash.
>
> coord = coord % (width-1); <— width is 1, so you get a coord = coord % 0
> and crash.
>
> As it happens, we should be using the clamp wrapping mode, but the crash
> would still hold for the scenario outlined above.
> But is this misuse or a valid issue?
>
> I’m using OIIO 1.7.10, Windows, VS2015 compiler.
>
> Best Regards,
> Simon
>
> ---
> Simon C Smith
> Co-Founder & CTO
> www.lightmap.co.uk <http://www.lightmap.co.uk/>
>
> Email confidentiality notice:
> This message is private and confidential. If you have received this message
> in error, please notify us and remove it from your system.
>
> _______________________________________________
> Oiio-dev mailing list
> [email protected]
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
--
Larry Gritz
[email protected]
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org