This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH - refresh] - print_rtx() robustness
- To: "Gcc-Patches (E-mail)" <gcc-patches at gcc dot gnu dot org>
- Subject: [PATCH - refresh] - print_rtx() robustness
- From: Donn Terry <donnte at microsoft dot com>
- Date: Tue, 27 Jun 2000 17:10:07 -0700
This patch was deferred "to a better time" a year ago.
print_rtx() can cause crash/debugger confusion if args are bad.
Problem: If the CODE field of a rtx is bad, print_rtx() will fail,
somewhat (although recoverably) confusing gdb. If used for runtime
debugging all is lost. If the value is far enough out of range,
it will SIGSEGV.
Fix: Rangecheck the code value, and gripe/fail soft if so.
ChangeLog
Mon Apr 27 10:38:22 1999 Donn Terry (donn@interix.com)
Refreshed: Tue Jun 27 17:02:50 PDT 2000 Donn Terry (donnte@microsoft.com)
* print-rtl.c (print_rtx): Fail soft on bad CODE value.
diff -urP egcs.source.old/gcc/print-rtl.c egcs.source/gcc/print-rtl.c
--- egcs.source.old/gcc/print-rtl.c Sun Apr 25 20:54:29 1999
+++ egcs.source/gcc/print-rtl.c Mon Apr 26 10:43:05 1999
@@ -73,7 +73,8 @@ print_rtx (in_rtx)
register const char *format_ptr;
register int is_insn;
rtx tem;
-
+ int cd;
+
if (sawclose)
{
fprintf (outfile, "\n%s",
@@ -88,6 +89,13 @@ print_rtx (in_rtx)
fputs ("(nil)", outfile);
sawclose = 1;
return;
+ }
+
+ cd = GET_CODE (in_rtx);
+ if (cd > NUM_RTX_CODE || cd < 0)
+ {
+ fprintf(outfile, "Bad rtx code %d\n", cd);
+ return;
}
is_insn = (GET_RTX_CLASS (GET_CODE (in_rtx)) == 'i');