Skip to content

Commit

Permalink
Issues/0150 max inst count segfault (#151)
Browse files Browse the repository at this point in the history
* add test for maxInstCount exception, improve exception message output

* increase maxInstCount to 100 million, fixes #150
  • Loading branch information
michaeldsmith authored Apr 21, 2024
1 parent 2adb330 commit f1c75e0
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 4 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ubuntu_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: run apt-get update
run: sudo apt-get -y update

- name: install test tool - valgrind
run: sudo apt-get -y install valgrind
Expand Down Expand Up @@ -237,7 +239,9 @@ jobs:
runs-on: ubuntu-latest

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: install test tool - valgrind
run: sudo apt-get -y install valgrind

Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/ubuntu_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: run apt-get update
run: sudo apt-get -y update

- name: install test tool - valgrind
run: sudo apt-get -y install valgrind
Expand Down Expand Up @@ -306,7 +308,9 @@ jobs:
runs-on: ubuntu-latest

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: install test tool - valgrind
run: sudo apt-get -y install valgrind

Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ RUN apt-get -y install libtiff-dev
WORKDIR /usr/src/CTL
COPY . .
WORKDIR /usr/src/CTL/build
RUN rm -R * || true
RUN cmake ..
RUN make
RUN make install
Expand Down
1 change: 1 addition & 0 deletions Dockerfile_openexr3
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ RUN apt-get -y install libtiff-dev
WORKDIR /usr/src/CTL
COPY . .
WORKDIR /usr/src/CTL/build
RUN rm -R * || true
RUN cmake ..
RUN make
RUN make install
Expand Down
2 changes: 1 addition & 1 deletion lib/IlmCtlSimd/CtlSimdInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ SimdInterpreter::SimdInterpreter():
Interpreter(),
_data (new Data)
{
_data->maxInstCount = 10000000;
_data->maxInstCount = 100000000;
_data->abortCount = 0;

//
Expand Down
6 changes: 5 additions & 1 deletion lib/IlmCtlSimd/CtlSimdXContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ SimdXContext::countInstruction ()
if ((++_instCount & 0x01fff) == 0)
{
if (_maxInstCount && _instCount > _maxInstCount)
throw Ctl::MaxInstExc ("Maximum CTL instruction count exceeded.");
THROW(Ctl::MaxInstExc, "\nException Ctl::MaxInstExc thrown\n" <<
"Maximum CTL instruction count _maxInstCount=" << _maxInstCount <<
" exceeded, _instCount=" << _instCount << "\n" <<
"Try increasing SimdInterpreter::Data->maxInstCount\n");
// throw Ctl::MaxInstExc ("Maximum CTL instruction count exceeded.");

if (_abortCount != _interpreter.abortCount())
throw Ctl::AbortExc ("CTL program aborted.");
Expand Down
21 changes: 21 additions & 0 deletions resources/test/ctl/throw_maxInstCount_exception.ctl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const unsigned int loop_limit = UINT_MAX;

void main
(input varying float rIn,
input varying float gIn,
input varying float bIn,
output varying float rOut,
output varying float gOut,
output varying float bOut
)
{
unsigned int x = 0;
for( unsigned int i = 0; i < loop_limit; i = i + 1)
{
x = i;
}

rOut = x;
gOut = x;
bOut = x;
}
Binary file added resources/test/exr/colorbars_nuke_rgb_exr16.exr
Binary file not shown.
5 changes: 5 additions & 0 deletions unittest/ctlrender/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,8 @@ if(OpenEXR_FOUND)
add_test(NAME "ctlrender-invalid-output-filename-exr" COMMAND ctlrender -force -format exr -ctl "${TEST_FILES}/unity.ctl" "${TEST_FILES}/colorbars_nuke_rgb_exr16.exr" "${CTLRENDER_OUTPUT_FOLDER}/missing_folder/invalid_filename_out.exr")
set_tests_properties("ctlrender-invalid-output-filename-exr" PROPERTIES WILL_FAIL TRUE)
endif()

# test for maxInstCount exception
add_test(NAME "ctlrender-maxInstCount-exception" COMMAND ctlrender -force -ctl "${PROJECT_SOURCE_DIR}/resources/test/ctl/throw_maxInstCount_exception.ctl" "${PROJECT_SOURCE_DIR}/resources/test/exr/colorbars_nuke_rgb_exr16.exr" "${CTLRENDER_OUTPUT_FOLDER}/maxInstCount_exception.exr")
set_tests_properties("ctlrender-maxInstCount-exception" PROPERTIES WILL_FAIL TRUE)

0 comments on commit f1c75e0

Please sign in to comment.