diff mbox

don't confuse user when OOM happens

Message ID 0e84a101-c14b-aede-82e0-79c87aa39c7b@acm.org
State New
Headers show

Commit Message

Nathan Sidwell Aug. 14, 2017, 3:56 p.m. UTC
The thread at https://gcc.gnu.org/ml/gcc/2017-08/msg00090.html discusses 
the driver behaviour when OOM kills cc1plus or whatever.

This patch changes the driver so that if the inferior dies via INT, 
TERM, QUIT or KILL signals,  it emits a clearer message about what happened.

We've been using this patch inside Facebook for a while, and it's cut 
down on OOM-related bug reports.  So works for me :)

ok?

nathan

Comments

Richard Biener Aug. 15, 2017, 11:24 a.m. UTC | #1
On Mon, Aug 14, 2017 at 5:56 PM, Nathan Sidwell <nathan@acm.org> wrote:
> The thread at https://gcc.gnu.org/ml/gcc/2017-08/msg00090.html discusses the
> driver behaviour when OOM kills cc1plus or whatever.
>
> This patch changes the driver so that if the inferior dies via INT, TERM,
> QUIT or KILL signals,  it emits a clearer message about what happened.
>
> We've been using this patch inside Facebook for a while, and it's cut down
> on OOM-related bug reports.  So works for me :)
>
> ok?

Ok.

Thanks,
Richard.

> nathan
>
> --
> Nathan Sidwell
diff mbox

Patch

2017-08-14  Nathan Sidwell  <nathan@acm.org>

	* gcc.c (execute): Emit friendlier message if inferior is killed
	by an external cause.

Index: gcc.c
===================================================================
--- gcc.c	(revision 251093)
+++ gcc.c	(working copy)
@@ -3151,9 +3151,27 @@  execute (void)
 	      }
 	    else
 #endif
-	      internal_error_no_backtrace ("%s (program %s)",
-					   strsignal (WTERMSIG (status)),
-					   commands[i].prog);
+	      switch (WTERMSIG (status))
+		{
+		case SIGINT:
+		case SIGQUIT:
+		case SIGKILL:
+		case SIGTERM:
+		  /* The user (or environment) did something to the
+		     inferior.  Making this an ICE confuses the user
+		     into thinking there's a compiler bug.  Much more
+		     likely is the user or OOM killer nuked it.  */
+		  fatal_error (input_location,
+			       "%s signal terminated program %s",
+			       strsignal (WTERMSIG (status)),
+			       commands[i].prog);
+		  break;
+		default:
+		  /* The inferior failed to catch the signal.  */
+		  internal_error_no_backtrace ("%s (program %s)",
+					       strsignal (WTERMSIG (status)),
+					       commands[i].prog);
+		}
 	  }
 	else if (WIFEXITED (status)
 		 && WEXITSTATUS (status) >= MIN_FATAL_STATUS)