Patchwork Go patch committed: Don't crash on erroneous channel operation

login
register
mail settings
Submitter Ian Taylor
Date Dec. 22, 2010, 4:27 p.m.
Message ID <mcraajxhiwi.fsf@google.com>
Download mbox | patch
Permalink /patch/76432/
State New
Headers show

Comments

Ian Taylor - Dec. 22, 2010, 4:27 p.m.
This patch to the Go frontend avoids a crash when doing a channel send
or receive on erroneous values.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

diff -r 9634bcdbbbcc go/gogo-tree.cc
--- a/go/gogo-tree.cc	Wed Dec 22 08:19:33 2010 -0800
+++ b/go/gogo-tree.cc	Wed Dec 22 08:24:30 2010 -0800
@@ -2895,6 +2895,9 @@ 
 Gogo::send_on_channel(tree channel, tree val, bool blocking, bool for_select,
 		      source_location location)
 {
+  if (channel == error_mark_node || val == error_mark_node)
+    return error_mark_node;
+
   if (int_size_in_bytes(TREE_TYPE(val)) <= 8
       && !AGGREGATE_TYPE_P(TREE_TYPE(val))
       && !FLOAT_TYPE_P(TREE_TYPE(val)))
@@ -3029,6 +3032,9 @@ 
 Gogo::receive_from_channel(tree type_tree, tree channel, bool for_select,
 			   source_location location)
 {
+  if (type_tree == error_mark_node || channel == error_mark_node)
+    return error_mark_node;
+
   if (int_size_in_bytes(type_tree) <= 8
       && !AGGREGATE_TYPE_P(type_tree)
       && !FLOAT_TYPE_P(type_tree))