From 7133fc29f4057c9d05415097a10a89fc58ecdaf3 Mon Sep 17 00:00:00 2001 From: michaeldsmith <37905569+michaeldsmith@users.noreply.github.com> Date: Tue, 2 Apr 2024 18:12:09 -0700 Subject: [PATCH] Issues/0146 strict aliasing violations (#147) * add docker to duplicate reported issue #146 * fix strict-aliasing issue * disable tiff on github workflow using vcpkg and in vcpkg.json dependencies due to security issue --- .github/workflows/docker_linuxes.yml | 12 +++++++++ .github/workflows/windows_vcpkg_debug.yml | 14 ++++++++--- .github/workflows/windows_vcpkg_release.yml | 14 ++++++++--- docker/Dockerfile_ubuntu_22.04_LTO | 27 +++++++++++++++++++++ lib/IlmCtlSimd/halfExpLog.h | 13 ++++++++-- lib/dpx/dpx_raw.cc | 5 +++- vcpkg.json | 3 +-- 7 files changed, 75 insertions(+), 13 deletions(-) create mode 100644 docker/Dockerfile_ubuntu_22.04_LTO diff --git a/.github/workflows/docker_linuxes.yml b/.github/workflows/docker_linuxes.yml index 1fe51e40..afe834d1 100644 --- a/.github/workflows/docker_linuxes.yml +++ b/.github/workflows/docker_linuxes.yml @@ -84,6 +84,18 @@ jobs: - name: Run ctlrender within the Docker image run: docker run ctl:latest sh -c "ctlrender -ctl /usr/src/aces-dev/transforms/ctl/utilities/ACESutil.Unity.ctl /usr/src/aces-dev/images/ACES/SonyF35.StillLife.exr /tmp/testout.exr" + ubuntu-22-04-LTO: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Build the Docker image + run: docker build --no-cache --rm -f ./docker/Dockerfile_ubuntu_22.04_LTO -t ctl:latest . + + - name: Run unit tests (ctest) within the Docker image + run: docker run ctl:latest sh -c "cd ./build && ctest" + ubuntu-23-10: runs-on: ubuntu-latest diff --git a/.github/workflows/windows_vcpkg_debug.yml b/.github/workflows/windows_vcpkg_debug.yml index 89848089..f2430c84 100644 --- a/.github/workflows/windows_vcpkg_debug.yml +++ b/.github/workflows/windows_vcpkg_debug.yml @@ -30,8 +30,11 @@ jobs: - name: install dependencies - openexr run: vcpkg install openexr - - name: install dependencies - tiff - run: vcpkg install tiff + # disabling tiff due to security issue + # https://github.com/microsoft/vcpkg/issues/37871 + # https://github.com/microsoft/vcpkg/issues/37839 + # - name: install dependencies - tiff + # run: vcpkg install tiff - name: check vcpkg install status run: vcpkg list @@ -66,8 +69,11 @@ jobs: - name: install dependencies - openexr run: vcpkg install openexr - - name: install dependencies - tiff - run: vcpkg install tiff + # disabling tiff due to security issue + # https://github.com/microsoft/vcpkg/issues/37871 + # https://github.com/microsoft/vcpkg/issues/37839 +# - name: install dependencies - tiff + # run: vcpkg install tiff - name: check vcpkg install status run: vcpkg list diff --git a/.github/workflows/windows_vcpkg_release.yml b/.github/workflows/windows_vcpkg_release.yml index 1231023c..8b1b1152 100644 --- a/.github/workflows/windows_vcpkg_release.yml +++ b/.github/workflows/windows_vcpkg_release.yml @@ -30,8 +30,11 @@ jobs: - name: install dependencies - openexr run: vcpkg install openexr:x64-windows - - name: install dependencies - tiff - run: vcpkg install tiff:x64-windows + # disabling tiff due to security issue + # https://github.com/microsoft/vcpkg/issues/37871 + # https://github.com/microsoft/vcpkg/issues/37839 + #- name: install dependencies - tiff + # run: vcpkg install tiff:x64-windows - name: check vcpkg install status run: vcpkg list @@ -66,8 +69,11 @@ jobs: - name: install dependencies - openexr run: vcpkg install openexr:x64-windows - - name: install dependencies - tiff - run: vcpkg install tiff:x64-windows + # disabling tiff due to security issue + # https://github.com/microsoft/vcpkg/issues/37871 + # https://github.com/microsoft/vcpkg/issues/37839 + #- name: install dependencies - tiff + # run: vcpkg install tiff:x64-windows - name: check vcpkg install status run: vcpkg list diff --git a/docker/Dockerfile_ubuntu_22.04_LTO b/docker/Dockerfile_ubuntu_22.04_LTO new file mode 100644 index 00000000..9272d984 --- /dev/null +++ b/docker/Dockerfile_ubuntu_22.04_LTO @@ -0,0 +1,27 @@ +FROM ubuntu:22.04 + +RUN apt-get update + +# disable interactive install +ENV DEBIAN_FRONTEND noninteractive + +# install developement tools +RUN apt-get -y install cmake +RUN apt-get -y install g++ + +# install CTL dependencies +RUN apt-get -y install libopenexr-dev +RUN apt-get -y install libtiff-dev + +# build CTL +WORKDIR /usr/src/CTL +COPY . . +WORKDIR /usr/src/CTL/build +RUN rm -R * || true +RUN cmake .. -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=TRUE -DCMAKE_VERBOSE_MAKEFILE=on -DCMAKE_CXX_FLAGS="-Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing" +RUN make +RUN make install + +# finalize docker environment +WORKDIR /usr/src/CTL + diff --git a/lib/IlmCtlSimd/halfExpLog.h b/lib/IlmCtlSimd/halfExpLog.h index 09dcfa2c..827ead9c 100644 --- a/lib/IlmCtlSimd/halfExpLog.h +++ b/lib/IlmCtlSimd/halfExpLog.h @@ -3,6 +3,7 @@ // Do not edit. // +#include extern const unsigned int log10Table[]; extern const unsigned int logTable[]; @@ -12,14 +13,22 @@ extern const unsigned short expTable[]; inline float log10_h (half x) { - return *(float *)(&log10Table[x.bits()]); + int i = log10Table[x.bits()]; + float f; + memcpy(&f, &i, sizeof(i)); + return f; + //return *(float *)(&log10Table[x.bits()]); } inline float log_h (half x) { - return *(float *)(&logTable[x.bits()]); + int i = logTable[x.bits()]; + float f; + memcpy(&f, &i, sizeof(i)); + return f; + //return *(float *)(&logTable[x.bits()]); } diff --git a/lib/dpx/dpx_raw.cc b/lib/dpx/dpx_raw.cc index 4f55a61a..353e674e 100644 --- a/lib/dpx/dpx_raw.cc +++ b/lib/dpx/dpx_raw.cc @@ -206,7 +206,10 @@ bool dpx::isnull(uint8_t v) { } bool dpx::isnull(float32_t v) { - return *((uint32_t *)&v)==(uint32_t)-1; + uint32_t u; + memcpy(&u, &v, sizeof(v)); + return (u == (uint32_t)-1) ? true : false; + //return *((uint32_t *)&v)==(uint32_t)-1; } } diff --git a/vcpkg.json b/vcpkg.json index 7b1adbc1..bc7153a4 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -3,7 +3,6 @@ "version": "1.5.3", "dependencies": [ "imath", - "openexr", - "tiff" + "openexr" ] }