pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/35010: sun3 emulator asserts when using stdin/stdout for emulated serial console



>Number:         35010
>Category:       pkg
>Synopsis:       sun3 emulator asserts when using stdin/stdout for emulated 
>serial console
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 07 17:30:00 +0000 2006
>Originator:     arthur townsend
>Release:        3.0
>Organization:
>Environment:
3.0 for i386
>Description:
host/posix/posix-serial.c, routine TME_ELEMENT_SUB_NEW_DECL shows that
stdin and stdout can be used as a serial device by using the device name
"-", as in the tmesh command

console0 at zs0 channel A: tme/host/posix/serial device - break-carats

but when using console device -, tme asserts upon startup

tmesh> assertion "tme_sjlj_fd_thread[fd] == NULL" failed: file 
"threads-sjlj.c", line 836, function "tme_sjlj_yield"
Abort trap (core dumped)


>How-To-Repeat:

>Fix:
The following patch to
  libtme/threads-sjlj.c
allows stdin/stdout to be used as the console device:


--- threads-sjlj.c.orig 2006-11-07 06:50:22.000000000 -0500
+++ threads-sjlj.c      2006-11-07 07:54:07.000000000 -0500
@@ -833,7 +833,9 @@
       if (fd_condition_new != 0) {
 
        /* this thread is now blocking on this fd: */
-       assert(tme_sjlj_fd_thread[fd] == NULL);
+
+        /* assert if this fd is already used - unless its stdin */
+       assert(tme_sjlj_fd_thread[fd] == NULL || fd == STDIN_FILENO);
        tme_sjlj_fd_thread[fd] = thread;
 
 #ifdef HAVE_GTK


So if one wanted to use the curent window as the console (and not use a GTK 
console or serial line console), the following can be done:
  1) apply above patch
  2) change "color-fb" to "ttya" in the my-sun3-eeprom.txt and .bin
  3) in the tmesh command startup script:
       a) use the console0 line shown above
       b) comment out the display0 lines
       c) command out the bwtwo0 and cgthree0 lines
  4) start tmesh with "tmesh --noninteractive"

after the emulated sun3 finishes booting, and you login as usual,
set the terminal via
   setenv TERM sun
to use vi and such.

--

Its not a bug, but since I'm having trouble locating tme's author directly, 
this seems like a good place to also mention:
If you want to startup an emulated sun3, but don't want to login via the
console (you want to login via ethernet), the following will startup the 
emulated sun3 without holding open an emulated serial line or terminal window:

tmesh --noninteractive z2 >& z2.log < z2 &

with the following console line in the tme command script z2:
console0 at zs0 channel A: tme/host/posix/serial device-input NONE device-output
 - break-carats

and all the other changes listed above, along with the following patch to:
  host/posix/posix-serial.c
so that NONE doesn't force a wait on a read from the emulated serial line:


--- posix-serial.c.orig 2006-11-07 06:29:39.000000000 -0500
+++ posix-serial.c      2006-11-07 08:23:59.000000000 -0500
@@ -839,6 +839,8 @@
   int saved_errno;
   int emulate_break;
 
+  int ignore_fd_in = FALSE;
+
   /* initialize: */
   filename_in = NULL;
   filename_out = NULL;
@@ -915,24 +917,32 @@
 
   /* open the devices: */
   fd_in = fd_out = -1;
-  if (fd_in < 0
-      && !strcmp(filename_in, "-")) {
-    fd_in = STDIN_FILENO;
+
+  ignore_fd_in = (strcmp(filename_in,"NONE") == 0);
+
+  if (!ignore_fd_in) {
+    if (fd_in < 0
+        && !strcmp(filename_in, "-")) {
+      fd_in = STDIN_FILENO;
+    }
   }
   if (fd_out < 0
       && !strcmp(filename_out, "-")) {
     fd_out = STDOUT_FILENO;
   }
-  if (fd_in < 0) {
-    if (strcmp(filename_in, filename_out) == 0) {
-      fd_in = fd_out = open(filename_in, O_RDWR | O_NONBLOCK);
-    }
-    else {
-      fd_in = open(filename_in, O_RDONLY | O_NONBLOCK);
-    }
+
+  if (!ignore_fd_in) {
     if (fd_in < 0) {
-      tme_output_append_error(_output, "%s", filename_in);
-      return (errno);
+      if (strcmp(filename_in, filename_out) == 0) {
+        fd_in = fd_out = open(filename_in, O_RDWR | O_NONBLOCK);
+      }
+      else {
+        fd_in = open(filename_in, O_RDONLY | O_NONBLOCK);
+      }
+      if (fd_in < 0) {
+        tme_output_append_error(_output, "%s", filename_in);
+        return (errno);
+      }
     }
   }
   if (fd_out < 0) {
@@ -962,7 +972,11 @@
   tme_mutex_init(&serial->tme_posix_serial_mutex);
   tme_cond_init(&serial->tme_posix_serial_cond_writer);
   tme_thread_create((tme_thread_t) _tme_posix_serial_th_writer, serial);
-  tme_thread_create((tme_thread_t) _tme_posix_serial_th_reader, serial);
+
+  if (!ignore_fd_in) {
+    tme_thread_create((tme_thread_t) _tme_posix_serial_th_reader, serial);
+  }
+
   tme_thread_create((tme_thread_t) _tme_posix_serial_th_ctrl, serial);
 
   /* fill the element: */



Both the above patch and the "< z2" or "< some-file-doesnt-matter" are needed 
to keep the emulated sun3 from hanging on bootup waiting for the input device.




Home | Main Index | Thread Index | Old Index