AcademySoftwareFoundation / AcademySoftwareFoundation/OpenImageIO
[BUG] OIIO does not compile with NDEBUG in precompile distribution
- Dominant language
- C++
- Stars
- 2.4k
- Forks
- 698
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 48
Description
**Describe the bug**
Ubuntu precompiled distributions of OIIO do not compile with NDEBUG defined for xmp.cpp.
The image loading output is confusing when metadata is not parsed. Client applications use OIIO to load images and emit unknown tags to stderr.
It appears as if either:
A. OIIO is not guarding the metadata dropping notices of xmp.cpp source as OIIO intends OR
B. the Ubuntu distributions should be building with NDEBUG defined.
**To Reproduce**
Steps to reproduce the behavior:
1. Install openimageio via precompiled library on Ubuntu 20.10 via package manager. Docker can make this quick. The version i used was from the repository as libopenimageio2.1/groovy, now 2.1.19.0~dfsg0-1build1
2. Load an image with "offending"/"not catalogued" metadata with ImageInput::open(...), that will drop through to the add_attrib xmp.cpp function bailout... specifically oiiotype is not one of the sections of the if/else blocks.
3. Observe errors emitted to stderr by openimageio up through the client application.
I observed the same issue on Ubuntu 18.04 and Ubuntu 20.04 and 20.10.
Unfortunately, I don't completely follow the metadata labeling tables that are exposing parsing omissions/errors.
**Expected behavior**
Expected behavior is somewhat subjective, but it could be:
1. Omit reporting metadata that is not parsed by openimageio. Accomplish this by:
1a. Requesting upstream sources like the Ubuntu repository build with NDEBUG on
1b. Use an environment variable or some other compile time guarding mechanism to enable openimageio to verbosely report metadata that is not parsed. Regarding NDEBUG usage, per a colleague: "Yet, if I correctly understand the intention of NDEBUG (as a standard preprocessor define) it is it control the firing of non-debug asserts. It is not meant as a control for “should I be verbose in message reporting”
2. Refer unknown tags to a source to make them known and ensure developers can reconcile correct behavior
It is possible this issue sighting could go to Ubuntu package maintainers... but perhaps it is best to start in the OIIO repository.
**Evidence**
Do you have error messages? (please quote exactly) Screenshots? Example
command lines or scripts that reliably reproduce the error? If it only
happens with certain image files, can you attach the smallest image you
can make that reproduces the problem?
I do not own the images to share for reproduction.
Please observe the buildlog for the Ubuntu groovy gorilla package linked through here:
https://launchpad.net/~ci-train-ppa-service/+archive/ubuntu/4246-deletedppa/+build/19915647
Notice in the log that the xmp.cpp build omits NDEBUG:
```
[ 19%] Building CXX object src/libOpenImageIO/CMakeFiles/OpenImageIO.dir/xmp.cpp.o
cd "/<>/build/src/libOpenImageIO" && /usr/bin/c++ -DEMBED_PLUGINS=1 -DOpenImageIO_EXPORTS -DUSE_BOOST_ASIO=1 -DUSE_DCMTK=1 -DUSE_FFMPEG -DUSE_FREETYPE=1 -DUSE_GIF -DUSE_LIBRAW=1 -DUSE_OCIO=1 -DUSE_OPENCOLORIO=1 -DUSE_OPENCV=1 -DUSE_OPENJPEG -DUSE_OPENVDB=1 -DUSE_STD_REGEX -DUSE_TBB=1 -DUSE_WEBP=1 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -I"/<>/build/include" -I"/<>/build/src/include" -I"/<>/src/include" -I/usr/include/OpenEXR -I/usr/include/openjpeg-2.3 -I/usr/include/opencv4 -I/usr/include/freetype2 -g -O2 -fdebug-prefix-map=/<>=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Wall -Wno-unused-local-typedefs -Wno-unused-result -Wno-aligned-new -Wno-noexcept-type -fno-math-errno -std=c++11 -Wno-error=placement-new -o CMakeFiles/OpenImageIO.dir/xmp.cpp.o -c "/<>/src/libOpenImageIO/xmp.cpp"
```
For reference, the code in question from xmp.cpp is from the add_attrib function:
```
#if (!defined(NDEBUG) || DEBUG_XMP_READ)
else {
std::cerr << "iptc xml add_attrib unknown type " << xmlname << ' '
<< oiiotype.c_str() << "\n";
}
#endif
```
I'm using the ImageInput::open routine and observing the unknown reports with pngs and tiffs... apparently via the related call stack: spec(), read_spec(...), decode_xmp(...), add_attrib(...).
At the risk of being pedantic.... Here is an example of tags that fall through for a tiff
```
iptc xml add_attrib unknown type photoshop:ColorMode unknown
iptc xml add_attrib unknown type photoshop:ICCProfile unknown
iptc xml add_attrib unknown type photoshop:DocumentAncestors unknown
iptc xml add_attrib unknown type rdf:parseType unknown
iptc xml add_attrib unknown type stEvt:action unknown
iptc xml add_attrib unknown type stEvt:instanceID unknown
iptc xml add_attrib unknown type stEvt:when unknown
iptc xml add_attrib unknown type stEvt:softwareAgent unknown
iptc xml add_attrib unknown type rdf:parseType unknown
iptc xml add_attrib unknown type stEvt:action unknown
iptc xml add_attrib unknown type stEvt:instanceID unknown
iptc xml add_attrib unknown type stEvt:when unknown
iptc xml add_attrib unknown type stEvt:softwareAgent unknown
iptc xml add_attrib unknown type stEvt:changed unknown
iptc xml add_attrib unknown type rdf:parseType unknown
iptc xml add_attrib unknown type stEvt:action unknown
iptc xml add_attrib unknown type stEvt:instanceID unknown
iptc xml add_attrib unknown type stEvt:when unknown
iptc xml add_attrib unknown type stEvt:softwareAgent unknown
iptc xml add_attrib unknown type stEvt:changed unknown
iptc xml add_attrib unknown type rdf:parseType unknown
iptc xml add_attrib unknown type stEvt:action unknown
iptc xml add_attrib unknown type stEvt:instanceID unknown
iptc xml add_attrib unknown type stEvt:when unknown
iptc xml add_attrib unknown type stEvt:softwareAgent unknown
iptc xml add_attrib unknown type stEvt:changed unknown
iptc xml add_attrib unknown type rdf:parseType unknown
iptc xml add_attrib unknown type stEvt:action unknown
iptc xml add_attrib unknown type stEvt:instanceID unknown
iptc xml add_attrib unknown type stEvt:when unknown
iptc xml add_attrib unknown type stEvt:softwareAgent unknown
iptc xml add_attrib unknown type stEvt:changed unknown
iptc xml add_attrib unknown type rdf:parseType unknown
iptc xml add_attrib unknown type stEvt:action unknown
iptc xml add_attrib unknown type stEvt:instanceID unknown
iptc xml add_attrib unknown type stEvt:when unknown
iptc xml add_attrib unknown type stEvt:softwareAgent unknown
iptc xml add_attrib unknown type stEvt:changed unknown
iptc xml add_attrib unknown type rdf:parseType unknown
iptc xml add_attrib unknown type stEvt:action unknown
iptc xml add_attrib unknown type stEvt:instanceID unknown
iptc xml add_attrib unknown type stEvt:when unknown
iptc xml add_attrib unknown type stEvt:softwareAgent unknown
iptc xml add_attrib unknown type stEvt:changed unknown
iptc xml add_attrib unknown type rdf:parseType unknown
iptc xml add_attrib unknown type stEvt:action unknown
iptc xml add_attrib unknown type stEvt:parameters unknown
iptc xml add_attrib unknown type rdf:parseType unknown
iptc xml add_attrib unknown type stEvt:action unknown
iptc xml add_attrib unknown type stEvt:parameters unknown
iptc xml add_attrib unknown type rdf:parseType unknown
iptc xml add_attrib unknown type stEvt:action unknown
iptc xml add_attrib unknown type stEvt:instanceID unknown
iptc xml add_attrib unknown type stEvt:when unknown
iptc xml add_attrib unknown type stEvt:softwareAgent unknown
iptc xml add_attrib unknown type stEvt:changed unknown
iptc xml add_attrib unknown type rdf:parseType unknown
iptc xml add_attrib unknown type stRef:instanceID unknown
iptc xml add_attrib unknown type stRef:documentID unknown
iptc xml add_attrib unknown type stRef:originalDocumentID unknown
```
From a png:
```
iptc xml add_attrib unknown type photoshop:ColorMode unknown
iptc xml add_attrib unknown type photoshop:DocumentAncestors unknown
iptc xml add_attrib unknown type photoshop:DocumentAncestors unknown
iptc xml add_attrib unknown type photoshop:DocumentAncestors unknown
iptc xml add_attrib unknown type rdf:parseType unknown
iptc xml add_attrib unknown type stEvt:action unknown
iptc xml add_attrib unknown type stEvt:instanceID unknown
iptc xml add_attrib unknown type stEvt:when unknown
iptc xml add_attrib unknown type stEvt:softwareAgent unknown
iptc xml add_attrib unknown type rdf:parseType unknown
iptc xml add_attrib unknown type stEvt:action unknown
iptc xml add_attrib unknown type stEvt:instanceID unknown
iptc xml add_attrib unknown type stEvt:when unknown
iptc xml add_attrib unknown type stEvt:softwareAgent unknown
iptc xml add_attrib unknown type stEvt:changed unknown
iptc xml add_attrib unknown type rdf:parseType unknown
iptc xml add_attrib unknown type stEvt:action unknown
iptc xml add_attrib unknown type stEvt:instanceID unknown
iptc xml add_attrib unknown type stEvt:when unknown
iptc xml add_attrib unknown type stEvt:softwareAgent unknown
iptc xml add_attrib unknown type stEvt:changed unknown
```
From another tiff:
```
iptc xml add_attrib unknown type tiff:ImageWidth unknown
iptc xml add_attrib unknown type tiff:ImageLength unknown
iptc xml add_attrib unknown type tiff:BitsPerSample unknown
iptc xml add_attrib unknown type tiff:BitsPerSample unknown
iptc xml add_attrib unknown type tiff:BitsPerSample unknown
iptc xml add_attrib unknown type tiff:SamplesPerPixel unknown
iptc xml add_attrib unknown type tiff:NativeDigest unknown
iptc xml add_attrib unknown type xap:ModifyDate unknown
iptc xml add_attrib unknown type xap:CreatorTool unknown
iptc xml add_attrib unknown type xap:CreateDate unknown
iptc xml add_attrib unknown type xap:MetadataDate unknown
iptc xml add_attrib unknown type photoshop:ColorMode unknown
iptc xml add_attrib unknown type rdf:parseType unknown
iptc xml add_attrib unknown type xapMM:InstanceID unknown
iptc xml add_attrib unknown type xapMM:DocumentID unknown
iptc xml add_attrib unknown type exif:NativeDigest unknown
```
My first intuition when seeing these errors was to think I was missing a prerequisite library that contained these attributes. I became really concerned that image data would be parsed incorrectly, or maybe needed to be transformed. Is there any primer on imaging xml attributes? I'm liable to see images written by unknown applications with varying metadata and it could be useful to understand best practices... or what is an acceptable gap w.r.t. OIIO loading.
**Platform information:**
- OIIO branch/version: Ubuntu 20.10 repository: libopenimageio2.1/groovy, now 2.1.19.0~dfsg0-1build1
- OS: Ubuntu 20.10 x86_64
- C++ compiler: g++ 10.2.0-13ubuntu1
- Any non-default build flags when you build OIIO: Please refer to the build log from the Ubuntu repository to see how they build their xmp.cpp source file (and the rest of OIIO as needed). I observed different build flags from my own default *off-the-shelf/git clone build* from the repo, which defined NDEBUG.
Thanks for your attention... I hope this report is constructive. Really appreciate OIIO... its a great library.
-MichaelC
Contributor guide
Research direction
Start with src/libOpenImageIO/xmp.cpp, especially add_attrib and its NDEBUG/DEBUG_XMP_READ guard, then reproduce the stderr output with ImageInput::open on PNG or TIFF metadata. Compare the Ubuntu build log with a normal OIIO build and determine the intended behavior for unknown XMP attributes. Done means the agreed behavior is verified without incorrectly handling image metadata.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100