From ae1ca5822e198be17aa602f2f8d3b83871ba44a8 Mon Sep 17 00:00:00 2001
From: Matt Birkholz <puck@birchwood-abbey.net>
Date: Wed, 25 Nov 2015 14:47:09 -0700
Subject: [PATCH] 9.2.1: fix elicit:underflow:least-positive-number-over-two

This cherry pick of 4fafc74 allows 9.2.1 to pass the elicit:underflow:
least-positive-number-over-two test.
---
 src/microcode/uxtrap.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/microcode/uxtrap.c b/src/microcode/uxtrap.c
index 511f112e2..6e7db83ba 100644
--- a/src/microcode/uxtrap.c
+++ b/src/microcode/uxtrap.c
@@ -391,6 +391,23 @@ continue_from_trap (int signo, SIGINFO_T info, SIGCONTEXT_T * scp)
 #endif
 
     case pcl_unknown:
+      if (((OBJECT_TYPE (primitive)) == TC_PRIMITIVE)
+	  && (ADDRESS_IN_STACK_P (stack_pointer)) && (ALIGNED_P (stack_pointer))
+	  && (ADDRESS_IN_HEAP_P (Free)) && (ALIGNED_P (Free)))
+	{
+#ifdef ENABLE_DEBUGGING_TOOLS
+	  if (GC_Debug == true)
+	    {
+	      /* Note where this presumption is employed. */
+	      outf_error (";Warning: trap at 0x%lx assumed a primitive\n", pc);
+	      outf_flush_error ();
+	    }
+#endif
+	  new_sp = stack_pointer;
+	  SET_RECOVERY_INFO
+	    (STATE_PRIMITIVE, primitive, (ULONG_TO_FIXNUM (GET_LEXPR_ACTUALS)));
+	  break;
+	}
       new_sp = 0;
       SET_RECOVERY_INFO
 	(STATE_UNKNOWN,
@@ -409,8 +426,13 @@ continue_from_trap (int signo, SIGINFO_T info, SIGCONTEXT_T * scp)
 	&& (ALIGNED_P (Free))))
     {
 #ifdef ENABLE_DEBUGGING_TOOLS
-      outf_error ("Resetting bogus Free in continue_from_trap.\n");
-      outf_flush_error ();
+      if (GC_Debug == true)
+	{
+	  outf_error ((new_sp == 0)
+		      ? ";Warning: bogus stack_pointer in continue_from_trap\n"
+		      : ";Warning: bogus Free in continue_from_trap\n");
+	  outf_flush_error ();
+	}
 #endif
       Free = heap_alloc_limit;
     }
-- 
2.25.1