https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97969
Bug ID: 97969 Summary: [ARM/Thumb] Certain combo of codegen options leads to compilation infinite loop with growing memory use Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: pmiscml at gmail dot com Target Milestone: --- Created attachment 49619 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49619&action=edit Testcase minimized with CReduce Attached in the creduce-minimized source code (and original preprocessed source) which, when compiled with ARM (32-bit) targeting compiler with certain options, and a code with setjmp(), leads to an apparent infinite loop with ever-growing memory usage. Specific command line to reproduce the issue is: arm-zephyr-eabi-gcc -std=c99 \ -fno-omit-frame-pointer \ -mthumb \ -Os \ -x cpp-output -c js-parser_cpp.c The combo of 3 of "-fno-omit-frame-pointer -mthumb -Os" is what causes the issue. Removing any of them gets rid of it. The issue is not speculative - it happens with JerryScript project (https://github.com/jerryscript-project/jerryscript/) build against Zephyr RTOS (https://github.com/zephyrproject-rtos/zephyr/) for a Cortex-M0 target (original gcc options included -mcpu=cortex-m0plus, but as the issue is reproducible with just -mthumb, I didn't include it above). The nature of the issue is pretty DoS'ish/CVE'ish, indeed, it caused our AWS-based CI to run builds for 12+ hrs (which normally take 10 mins). The issue happens with GCC 10.2, which is the latest at the time of reporting, but also with 9.2.0. Specific GCC build comes from the SDK of the mentioned Zephyr RTOS, which is built using Crosstool-NG, definitely with some patches, but shouldn't be anything serious which might cause such behavior. It's however my intention to try other toolchains, I just decided first to record currently available information in this ticket. $ /home/pfalcon/opt/zephyr-sdk-0.12.0b1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -v Using built-in specs. COLLECT_GCC=/home/pfalcon/opt/zephyr-sdk-0.12.0b1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc COLLECT_LTO_WRAPPER=/mnt/hdd/opt/zephyr-sdk-0.12.0b1/arm-zephyr-eabi/bin/../libexec/gcc/arm-zephyr-eabi/10.2.0/lto-wrapper Target: arm-zephyr-eabi Configured with: /workdir/build/build_arm/.build/arm-zephyr-eabi/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=arm-zephyr-eabi --prefix=/workdir/build/output/arm-zephyr-eabi --with-local-prefix=/workdir/build/output/arm-zephyr-eabi/arm-zephyr-eabi --with-headers=/workdir/build/output/arm-zephyr-eabi/arm-zephyr-eabi/include --with-newlib --enable-threads=no --disable-shared --with-pkgversion='crosstool-NG 1.24.0.192_9551914' --enable-__cxa_atexit --disable-libgomp --disable-libmudflap --disable-libmpx --disable-libssp --disable-libquadmath --disable-libquadmath-support --with-gmp=/workdir/build/build_arm/.build/arm-zephyr-eabi/buildtools --with-mpfr=/workdir/build/build_arm/.build/arm-zephyr-eabi/buildtools --with-mpc=/workdir/build/build_arm/.build/arm-zephyr-eabi/buildtools --with-isl=/workdir/build/build_arm/.build/arm-zephyr-eabi/buildtools --enable-lto --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --disable-nls --enable-multiarch --with-multilib-list=rmprofile --enable-languages=c,c++ --with-gnu-ld --with-gnu-as --enable-initfini-array Thread model: single Supported LTO compression algorithms: zlib gcc version 10.2.0 (crosstool-NG 1.24.0.192_9551914) $ /home/pfalcon/opt/zephyr-sdk-0.11.4/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -v Using built-in specs. COLLECT_GCC=/home/pfalcon/opt/zephyr-sdk-0.11.4/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc COLLECT_LTO_WRAPPER=/mnt/hdd/opt/zephyr-sdk-0.11.4/arm-zephyr-eabi/bin/../libexec/gcc/arm-zephyr-eabi/9.2.0/lto-wrapper Target: arm-zephyr-eabi Configured with: /home/buildslave/src/github.com/zephyrproject-rtos/sdk-ng/build/build_arm/.build/arm-zephyr-eabi/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=arm-zephyr-eabi --prefix=/home/buildslave/src/github.com/zephyrproject-rtos/sdk-ng/build/output/arm-zephyr-eabi --with-local-prefix=/home/buildslave/src/github.com/zephyrproject-rtos/sdk-ng/build/output/arm-zephyr-eabi/arm-zephyr-eabi --with-headers=/home/buildslave/src/github.com/zephyrproject-rtos/sdk-ng/build/output/arm-zephyr-eabi/arm-zephyr-eabi/include --with-newlib --enable-threads=no --disable-shared --with-pkgversion='crosstool-NG 1.24.0.37-3f461da-dirty' --enable-__cxa_atexit --disable-libgomp --disable-libmudflap --disable-libmpx --disable-libssp --disable-libquadmath --disable-libquadmath-support --with-gmp=/home/buildslave/src/github.com/zephyrproject-rtos/sdk-ng/build/build_arm/.build/arm-zephyr-eabi/buildtools --with-mpfr=/home/buildslave/src/github.com/zephyrproject-rtos/sdk-ng/build/build_arm/.build/arm-zephyr-eabi/buildtools --with-mpc=/home/buildslave/src/github.com/zephyrproject-rtos/sdk-ng/build/build_arm/.build/arm-zephyr-eabi/buildtools --with-isl=/home/buildslave/src/github.com/zephyrproject-rtos/sdk-ng/build/build_arm/.build/arm-zephyr-eabi/buildtools --enable-lto --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --disable-nls --enable-multiarch --with-multilib-list=rmprofile --enable-languages=c,c++ --with-gnu-ld --with-gnu-as --enable-initfini-array Thread model: single gcc version 9.2.0 (crosstool-NG 1.24.0.37-3f461da-dirty)