From f1c75e0d6a08b46e4eccc1fe0cf62e250e9fbd8b Mon Sep 17 00:00:00 2001 From: michaeldsmith <37905569+michaeldsmith@users.noreply.github.com> Date: Sat, 20 Apr 2024 22:03:23 -0700 Subject: [PATCH] Issues/0150 max inst count segfault (#151) * add test for maxInstCount exception, improve exception message output * increase maxInstCount to 100 million, fixes #150 --- .github/workflows/ubuntu_debug.yml | 6 ++++- .github/workflows/ubuntu_release.yml | 6 ++++- Dockerfile | 1 + Dockerfile_openexr3 | 1 + lib/IlmCtlSimd/CtlSimdInterpreter.cpp | 2 +- lib/IlmCtlSimd/CtlSimdXContext.cpp | 6 ++++- .../test/ctl/throw_maxInstCount_exception.ctl | 21 ++++++++++++++++++ .../test/exr/colorbars_nuke_rgb_exr16.exr | Bin 0 -> 18102 bytes unittest/ctlrender/CMakeLists.txt | 5 +++++ 9 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 resources/test/ctl/throw_maxInstCount_exception.ctl create mode 100644 resources/test/exr/colorbars_nuke_rgb_exr16.exr diff --git a/.github/workflows/ubuntu_debug.yml b/.github/workflows/ubuntu_debug.yml index f769d006..e705b9f0 100644 --- a/.github/workflows/ubuntu_debug.yml +++ b/.github/workflows/ubuntu_debug.yml @@ -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 @@ -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 diff --git a/.github/workflows/ubuntu_release.yml b/.github/workflows/ubuntu_release.yml index 99b24c52..db05da58 100644 --- a/.github/workflows/ubuntu_release.yml +++ b/.github/workflows/ubuntu_release.yml @@ -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 @@ -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 diff --git a/Dockerfile b/Dockerfile index bc01d26b..bd9f720b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Dockerfile_openexr3 b/Dockerfile_openexr3 index 2fd496ac..73b9df7d 100644 --- a/Dockerfile_openexr3 +++ b/Dockerfile_openexr3 @@ -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 diff --git a/lib/IlmCtlSimd/CtlSimdInterpreter.cpp b/lib/IlmCtlSimd/CtlSimdInterpreter.cpp index cdcf6a84..43a02dac 100644 --- a/lib/IlmCtlSimd/CtlSimdInterpreter.cpp +++ b/lib/IlmCtlSimd/CtlSimdInterpreter.cpp @@ -86,7 +86,7 @@ SimdInterpreter::SimdInterpreter(): Interpreter(), _data (new Data) { - _data->maxInstCount = 10000000; + _data->maxInstCount = 100000000; _data->abortCount = 0; // diff --git a/lib/IlmCtlSimd/CtlSimdXContext.cpp b/lib/IlmCtlSimd/CtlSimdXContext.cpp index 6797cc9a..1b9fa181 100644 --- a/lib/IlmCtlSimd/CtlSimdXContext.cpp +++ b/lib/IlmCtlSimd/CtlSimdXContext.cpp @@ -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."); diff --git a/resources/test/ctl/throw_maxInstCount_exception.ctl b/resources/test/ctl/throw_maxInstCount_exception.ctl new file mode 100644 index 00000000..ca05a4fe --- /dev/null +++ b/resources/test/ctl/throw_maxInstCount_exception.ctl @@ -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; +} diff --git a/resources/test/exr/colorbars_nuke_rgb_exr16.exr b/resources/test/exr/colorbars_nuke_rgb_exr16.exr new file mode 100644 index 0000000000000000000000000000000000000000..b83b99f5feba285ab04fe4cd898f25ee0f877a6b GIT binary patch literal 18102 zcmd6sc~Dhl7{(8{WGXER$l`{$kSj}wOQ|Wj3kDckDO|Y+xq7*mxK{)%K{O&WO3O+k zLnYHPGcqf;a<`Zd9B$X&-pd92 z?KZD1-QlvkXBku7g|QCfI^U-auVUZIao=Efc=DXKqW|4{(L8QFNmI-ME5%b58YE?chYF&r+h(HQrt-*CC@W=4+9lVfR%$ODTnKIlFM^S+)!yyk1K>9BTd-50+M58DgImFGz=$BVmj>PsZUMgr zI|i%0RIm(u1H1rsXruO0!27`0!LPvfA!_e7Z~^!lcphvQs`kc%^TEyFIk0V*+DisY z!B@evV0gINO9JPCo4_x@u(oP%99ROr0-gaw+o`>=U@=$&egTHGS9@c?x!}v-X|PQP zwKp2P7u*Pb4hDBrd!xX6z?Z;NU{Hin{~8I-0XKl3fq|XW-Ux6u_#*fz*g8_}4F`+B z_25acRcEz#D_97=0Dc0t>VoTmv%wAEDKNOJ+8Yhd1#7@FU|2V`mjsrAo5Ay7`zW=S z0+xZ--Jm{S4tDOY<_%!K9%|kNj_s-DV_;@4HJ=B)z1931Sl&m?t)dkx!LBiC-Utqe zRr4M&DNfBNz^ON?`2tuFuV$mK;zBSmLCq_`sD5g$0dMNB=6&G!0c!pTv=3DCH(=pS zYWBZbaS<3iNX=DX_rYr31P&Ua<^y2LEo%N4%pR)di{R{GYHpmUSOJFIs^(Q-&*5s8 z@A4xltjx*@X|g&qa8c{Z{dmQn zR~qq3V_s>(D@}RjDqd;EE7B;)AElHFQfa{}QaQ-GNc$iaDI%mIorF}Ro{)+(6;hGX zLMqZuLuO#!zcwV`US5kN-l~>YuWdg6<&MWD>GLcs%@yZ>%awo6c#VeC}WeTrk@Jc4H z*mz|suVnFxomWg=$>x=5ypqE!4qlngD>Hb-$t$_M;^GxIujKK{-Mo^|D;{3)^2$tJ zDd3e^yi&+3MZ7YbSLX1_J-l)+ugv9@VqPiXm3h2U$}97EWdX0;$17#LazC$>^U4Ff zvXECEnduO_EjGBw4LZl4@;|JgZHTHQFS3 zPMaiawMnv0n~CHc7T=lVrO#Np@(HZk{r?|Nu4%H4r`O-eQlB) W(I&}JZIXPTO_F2UBss24l0N_`iFY;t literal 0 HcmV?d00001 diff --git a/unittest/ctlrender/CMakeLists.txt b/unittest/ctlrender/CMakeLists.txt index 1c05f708..67f24b25 100644 --- a/unittest/ctlrender/CMakeLists.txt +++ b/unittest/ctlrender/CMakeLists.txt @@ -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) +