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

File output safety for oiiotool #1797

Merged
merged 1 commit into from
Oct 31, 2017

Conversation

lgritz
Copy link
Collaborator

@lgritz lgritz commented Oct 28, 2017

maketx (really, the underlying IBA::make_texture() call) writes to a
temporary output file, then after it's done, atomically moves the file
to its requested destination. This ensures proper operation if the user
foolishly specifies that output should overwrite input (same file), and
also is a guard against a crashing program leaving a corrupted
half-written file behind that could be mistaken for proper output.

This patch employs the same trick to oiiotool. It was "safe" to have

oiiotool in.exr ...blah... -o in.exr

if in.exr was small enough -- in which case it would be fully read into
its ImageBuf when first encountered. But if it was a large file, it would
rely on ImageCache, so it was possible that when the output started to
overwrite it, trashing the file, not all the parts of the image had been
read into memory. With this patch, that should no longer be a danger.
We also do an ImageCache invalidation of the file that was output, in case
an portions are being used somehow.

maketx (really, the underlying IBA::make_texture() call) writes to a
temporary output file, then after it's done, atomically moves the file
to its requested destination. This ensures proper operation if the user
foolishly specifies that output should overwrite input (same file), and
also is a guard against a crashing program leaving a corrupted
half-written file behind that could be mistaken for proper output.

This patch employs the same trick to oiiotool. It was "safe" to have

    oiiotool in.exr ...blah... -o in.exr

if in.exr was small enough -- in which case it would be fully read into
its ImageBuf when first encountered. But if it was a large file, it would
rely on ImageCache, so it was possible that when the output started to
overwrite it, trashing the file, not all the parts of the image had been
read into memory. With this patch, that should no longer be a danger.
We also do an ImageCache invalidation of the file that was output, in case
an portions are being used somehow.
@lgritz lgritz merged commit 01b0e65 into AcademySoftwareFoundation:master Oct 31, 2017
lgritz added a commit to lgritz/OpenImageIO that referenced this pull request Nov 1, 2017
maketx (really, the underlying IBA::make_texture() call) writes to a
temporary output file, then after it's done, atomically moves the file
to its requested destination. This ensures proper operation if the user
foolishly specifies that output should overwrite input (same file), and
also is a guard against a crashing program leaving a corrupted
half-written file behind that could be mistaken for proper output.

This patch employs the same trick to oiiotool. It was "safe" to have

    oiiotool in.exr ...blah... -o in.exr

if in.exr was small enough -- in which case it would be fully read into
its ImageBuf when first encountered. But if it was a large file, it would
rely on ImageCache, so it was possible that when the output started to
overwrite it, trashing the file, not all the parts of the image had been
read into memory. With this patch, that should no longer be a danger.
We also do an ImageCache invalidation of the file that was output, in case
an portions are being used somehow.
@lgritz lgritz deleted the lg-oiiotoolwrite branch November 11, 2017 00:20
GerHobbelt pushed a commit to GerHobbelt/oiio that referenced this pull request Dec 10, 2024
…s for the CIs (AcademySoftwareFoundation#1797)

* Changed OCIO_PYTHON_LOAD_DLLS_FROM_PATH to opt-in instead of opt-out

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>

* Restrict the version of urllib3 to version <2 because version above this is not compatible with the OCIO container images

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>

* Revert unwanted change from this branch

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>

---------

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant