Skip to content

Commit

Permalink
Issues/0146 strict aliasing violations (#147)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
michaeldsmith authored Apr 3, 2024
1 parent a63c7ec commit 7133fc2
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 13 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/docker_linuxes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/windows_vcpkg_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/windows_vcpkg_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions docker/Dockerfile_ubuntu_22.04_LTO
Original file line number Diff line number Diff line change
@@ -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

13 changes: 11 additions & 2 deletions lib/IlmCtlSimd/halfExpLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Do not edit.
//

#include <string.h>

extern const unsigned int log10Table[];
extern const unsigned int logTable[];
Expand All @@ -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()]);
}


Expand Down
5 changes: 4 additions & 1 deletion lib/dpx/dpx_raw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
3 changes: 1 addition & 2 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "1.5.3",
"dependencies": [
"imath",
"openexr",
"tiff"
"openexr"
]
}

0 comments on commit 7133fc2

Please sign in to comment.