Subject: pkg/35183: TME sun3 emulator asserts when attempting to start M68K instruction
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <sigmfsk@aol.com>
List: pkgsrc-bugs
Date: 12/04/2006 13:55:00
>Number:         35183
>Category:       pkg
>Synopsis:       TME sun3 emulator asserts when attempting to start M68K instruction
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 04 13:55:00 +0000 2006
>Originator:     Arthur Townsend
>Release:        3.1
>Organization:
>Environment:
3.1 for i386
>Description:
TME asserts when attempting to make chimera from pkgsrc.  Patch file below changes TME to continue with a warning (rather than exiting under assert).  Please see the patch file below for specifics on what happens in the console in the emulator if the assertion is ignored.
>How-To-Repeat:
Inside the emulator (running NetBSD 3.0 and pkgsrc 2006Q3, cd /usr/pkgsrc/www/chimera, then make.
>Fix:
--- m68k-execute.c.orig3        2006-11-19 11:22:47.000000000 -0500
+++ m68k-execute.c      2006-11-19 11:27:07.000000000 -0500
@@ -37,6 +37,13 @@
 
 /* includes: */
 #include "m68k-auto.h"
+#include <stdio.h>
+
+char hitreturn;
+#define HITRETURN \
+printf("press return to continue:"); \
+scanf("%c",&hitreturn); \
+printf("continuing\n");
 
 /* the m68k instruction executor: */
 static void
@@ -823,9 +830,45 @@
        || (ic->_tme_m68k_mode_flags & TME_M68K_EXECUTION_INST_CANFAULT)) {
       transfer_next_before = ic->_tme_m68k_sequence._tme_m68k_sequence_transfer_next;
       (*func)(ic, TME_M68K_OPCODE_OP0_WHICH(ic, params), TME_M68K_OPCODE_OP1_WHICH(ic, params));
+
+/* the following asserts during make under /usr/pkgsrc/www/chimera under
+   netbsd 3.0 in the emulator with 2006Q3 pkgsrc.
+
+   if the assertion is printed instead of aborting, TME asserts three times,
+   at pc's: 20eff5c, 20eff5c, 20cff5c
+
+   all three take place immediately after the console logs:
+
+[lots of build messages, then]
+rm -f chimera._man
+cd 'dirname chimera' && ln -s 'basename chimera.man' 'basename chimera._man'
+ 
+   after TME asserts three times, the console continues with:
+
+[1] Segmentation fault (core dumped) PATH="${GROFF_RU...
+[1] Done                    cat chimera._man |
+    Segmentation fault (core dumped) neqn -Tlatin1 |
+    Segmentation fault (core dumped) tbl |
+    Done(139)               nroff -Tlatin1 -man |
+    Done                    col >chimera.0
+=> Unwrapping files-to-be-installed.
+
+   I don't know the problem, but at least stop and log so that we know
+   that it happened (and see if we can workaround)
+
       assert(!(ic->_tme_m68k_mode_flags & TME_M68K_EXECUTION_INST_CANFAULT)
             != (ic->_tme_m68k_sequence._tme_m68k_sequence_transfer_next
                 != transfer_next_before));
+*/
+      if(!(!(ic->_tme_m68k_mode_flags & TME_M68K_EXECUTION_INST_CANFAULT)
+            != (ic->_tme_m68k_sequence._tme_m68k_sequence_transfer_next
+                != transfer_next_before))) {
+        printf(", pc:%x, please:\n",ic->tme_m68k_ireg_pc);
+        printf("  log what was happening when this occured to see if you have a workaround.\n");
+        printf("  your program (running in the emulator) is likely about to seg fault.\n");
+        HITRETURN
+      }
+
       ic->_tme_m68k_mode_flags &= ~TME_M68K_EXECUTION_INST_CANFAULT;
     }