[Bug target/97969] [9/10/11 Regression][ARM/Thumb] Certain combo of codegen options leads to compilation infinite loop with growing memory use

2021-01-13 Thread pmiscml at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97969

--- Comment #19 from Paul Sokolovsky  ---
Vladimir Makarov, Przemyslaw Wirkus: Thanks looking into this issue and fixing
it!

[Bug target/97969] [9/10/11 Regression][ARM/Thumb] Certain combo of codegen options leads to compilation infinite loop with growing memory use

2020-12-07 Thread pmiscml at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97969

--- Comment #11 from Paul Sokolovsky  ---
In my case, I used the "timeout" command from GNU coreutils. I've attached the
actual script used for reference (uncleaned dirty stuff, sorry).

One thing to keep in mind (and which took me a couple of extra creduce runs) is
that when it times out, it's the "interesting case" in CReduce terms. And when
compilation succeeds *or* fails (e.g. because CReduce produced broken syntax),
it's "not interesting case". So, you literally need to test for the timeout
exit code vs anything else (be it 0 or 1), like the script shows.

[Bug target/97969] [9/10/11 Regression][ARM/Thumb] Certain combo of codegen options leads to compilation infinite loop with growing memory use

2020-12-07 Thread pmiscml at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97969

--- Comment #10 from Paul Sokolovsky  ---
Created attachment 49693
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49693&action=edit
Script for CReduce

[Bug target/97969] [9/10/11 Regression][ARM/Thumb] Certain combo of codegen options leads to compilation infinite loop with growing memory use

2020-11-27 Thread pmiscml at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97969

--- Comment #5 from Paul Sokolovsky  ---
ktkac...@gcc.gnu.org:

Thanks for looking into this issue! Looking forward for the root cause to be
found. Given the minimized testcase which CReduce came to, my finger-in-the-sky
bet would be that it's a very fine case of data structure corruption, which
doesn't lead to segfault, but rather to infiniloop.

I'm saying that, because I tried to play with the minimized example myself, but
saw that most changes get rid of the issue. The only "simplifying" change I
could make which still leads to infiniloop is replace usage of the "h" enum
with "char" ("int" doesn't work). That makes declaration of the "h" enum
unused, and yet removal of it fixes the loop. That's why I say it looks like
very fine memory corruption, it's hard to imagine how unused enum declaration
can affect regalloc.

But then, I don't have experience with this stuff, and the setup is too
complicated for me to try. So again, thanks for looking into this.

[Bug c/97969] [ARM/Thumb] Certain combo of codegen options leads to compilation infinite loop with growing memory use

2020-11-24 Thread pmiscml at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97969

--- Comment #2 from Paul Sokolovsky  ---
To confirm, GCC 9.3.1 from "gcc-arm-none-eabi-9-2020-q2-update" (as distributed
by Arm from
https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm)
also has this issue.

[Bug c/97969] [ARM/Thumb] Certain combo of codegen options leads to compilation infinite loop with growing memory use

2020-11-24 Thread pmiscml at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97969

--- Comment #1 from Paul Sokolovsky  ---
Created attachment 49620
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49620&action=edit
Preprocessed original source which caused the issue (js-parser.c from
JerryScript project)

[Bug c/97969] New: [ARM/Thumb] Certain combo of codegen options leads to compilation infinite loop with growing memory use

2020-11-24 Thread pmiscml at gmail dot com via Gcc-bugs
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/githu