https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87836
--- Comment #20 from Gary Mills <gary_mills at fastmail dot fm> ---
For a test, I defined the symbol DEBUG_ET in gcc-7.3.0/gcc/et-forest.c .
During
the build, I got this ICE and a backtrace:
/export/home/mills/Downloads/code/oi-userland/components/developer/gcc-7/build/sparcv7/./gcc/xgcc
-B/export/home/mills/Downloads/code/oi-userland/components/developer/gcc-7/build/sparcv7/./gcc/
-nostdinc -x c /dev/null -S -o /dev/null
-fself-test=/export/home/mills/Downloads/code/oi-userland/components/developer/gcc-7/gcc-7.3.0/gcc/testsuite/selftests
cc1: internal compiler error: Bus Error
The bus error occurs here, in gcc-7.3.0/gcc/et-forest.c:218:
203 static int
204 record_path_before_1 (struct et_occ *occ, int depth)
205 {
206 int mn, m;
207
208 depth += occ->depth;
209 mn = depth;
210
211 if (occ->prev)
212 {
213 m = record_path_before_1 (occ->prev, depth);
214 if (m < mn)
215 mn = m;
216 }
217
-------------------------------------------------------------------------------
218 fprintf (stderr, "%d (%d); ", ((basic_block) occ->of->data)->index,
depth);
-------------------------------------------------------------------------------
219
It's likely dereferencing a NULL pointer.
When I later tested xgcc with my trivial source file, I got this output:
<mills@t2000:1908>$ build/sparcv7/gcc/xgcc -B build/sparcv7/./gcc/ -S
/tmp/conftest.c
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
4 (0);
0 (0); 2 (1); 4 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
3 (0);
0 (0); 2 (1); 3 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
3 (0);
0 (0); 2 (1); 3 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
3 (0);
0 (0); 2 (1); 3 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
3 (0);
0 (0); 2 (1); 3 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
3 (0);
0 (0); 2 (1); 3 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
3 (0);
0 (0); 2 (1); 3 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
3 (0);
0 (0); 2 (1); 3 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
3 (0);
0 (0); 2 (1); 3 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
3 (0);
0 (0); 2 (1); 3 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
3 (0);
0 (0); 2 (1); 3 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
3 (0);
0 (0); 2 (1); 3 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
3 (0);
0 (0); 2 (1); 3 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
3 (0);
0 (0); 2 (1); 3 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
3 (0);
0 (0); 2 (1); 3 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
3 (0);
0 (0); 2 (1); 3 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
3 (0);
0 (0); 2 (1); 3 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
3 (0);
0 (0); 2 (1); 3 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0); 2 (1); 0 (0);
3 (0);
0 (0); 2 (1); 3 (2); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
0 (0);
2 (0);
0 (0); 2 (1); 0 (0);
The compile was successful. The output file, conftest.s, had the correct
assembly language. The debugging output from the compile showed each chain of
blocks within the tree structure. The first number is the index. The second,
in brackets, is the depth. There seems to be some unwanted chains in that
list.
These are always one block long and begin with a non-zero index. I don't know
the origin of these chains, but they likely cause the ICE when compiling a
regular file. How do I determine their origin?