🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Kristoffer H. Rose Tue, 14 Apr 1992 18:08
FIX for immediate Epoch-4.0p0 "memcpy(0) crash" when using GCC 2.1.
#108
Author: Kristoffer H. Rose
Date: Tue, 14 Apr 1992 18:08
130 lines
4165 bytes
If you can build Epoch-4.0p0 with GCC 2.1 but it crashes immediately
by attempting to do a mempcy(0) then this patch may be for you!

BUG REPORT:

* SYSTEM:	Sun 3/60 with SunOS 3.5 compiling with GCC 2.1.

* CONFIG: 	"s-bsd4-2.h", "m-sun3.h", and the extra "config.h" lines

	#define START_FILES crt0.o /lib/Mcrt1.o
	#define LIB_GCC "/usr/gnu/lib/gcc-lib/sun3-sunos3/2.1/libgcc.a" -lc
	#define LIBS_DEBUG

		but should apply to any system/configuration where it
		is unsafe to reference nonexisting arguments of
		function calls.

* PROBLEM:	Epoch (the X version) compiles fine, but when run
		immediately dumps core.  Gdb explains that this
		happens in message() of "xdispepoch.c" where a call to
		memcpy() with a NULL pointer is attempted.

* SOLUTION:	An investigation of message() reveals that it is
		declared with four arguments yet is not passed more
		than two in this case (!).  The following fix uses the
		GCC <stdarg.h> include file to retrieve the correct
		number of arguments when GCC is used.

* HOW TO APPLY:	1) Go to the "epoch-4.0p0/src" directory.
		2) Save this message as "xdispepoch.message.patch".
		3) Run "patch < xdispepoch.message.patch".
		4) Go to the "epoch-4.0p0" directory.
		5) Redo "make install" or "./build-install".

Regards,
    Kristoffer H{\o}gsbro ROSE                      <kris@diku.dk>
    DIKU (TOPPS group), University of Copenhagen
    Universitetsparken 1, DK-2100 Copenhagen {\O}  +45 31396466/213

--8<--------8<--------8<--------8<--------8<--------8<--------8<------
diff -c epoch-4.0p0/src/xdispepoch.c.orig epoch-4.0p0/src/xdispepoch.c
*** epoch-4.0p0/src/xdispepoch.c.orig	Wed Mar 25 18:42:12 1992
--- epoch-4.0p0/src/xdispepoch.c	Sat Apr 11 17:08:10 1992
***************
*** 422,431 ****
  int message_buf_print;
  
  /* dump an informative message to the minibuf */
  /* VARARGS 1 */
  message (m, a1, a2, a3)
!      char *m;
  {
    struct Root_Block *rb;
  
    rb = distinct_minibuffer ? mini_root : cur_root;
--- 422,442 ----
  int message_buf_print;
  
  /* dump an informative message to the minibuf */
+ 
+ /* cleaned up message() for GCC...Apr 14, 1992, <kris@diku.dk> */
+ 
+ #ifdef __GNUC__
+ #include <stdarg.h>
+ void message (char *m,...)
+ {
+   int a1,a2,a3; va_list ap;
+ #else
  /* VARARGS 1 */
  message (m, a1, a2, a3)
!     char *m;
  {
+ #endif /* __GNUC__ */
+ 
    struct Root_Block *rb;
  
    rb = distinct_minibuffer ? mini_root : cur_root;
***************
*** 435,441 ****
--- 446,458 ----
        if (noninteractive_need_newline)
  	putchar ('\n');
        noninteractive_need_newline = 0;
+ 
+ #ifdef __GNUC__
+       va_start(ap,m); vprintf (m, ap); va_end(ap);
+ #else
        printf (m, a1, a2, a3);
+ #endif /* __GNUC__ */
+ 
        printf ("\n");
        fflush (stdout);
      }
***************
*** 444,457 ****
--- 461,492 ----
        extern int printbufidx;
  #ifdef NO_ARG_ARRAY
        int a[3];
+ 
+ #ifdef __GNUC__
+       va_start(ap,m);
+       a[0] = va_arg(ap,int);
+       a[1] = va_arg(ap,int);
+       a[2] = va_arg(ap,int);
+       va_end(ap);
+ #else
        a[0] = a1;
        a[1] = a2;
        a[2] = a3;
+ #endif
  
        doprnt (message_buf, sizeof message_buf - 1, m, 3, a);
+ 
+ #else /* NO_ARG_ARRAY */
+ 
+ #ifdef __GNUC__
+       va_start(ap,m);
+       doprnt (message_buf, sizeof message_buf - 1, m, 3, ap);
+       va_end(ap);
  #else
        doprnt (message_buf, sizeof message_buf - 1, m, 3, &a1);
+ #endif /* __GNUC__ */
  #endif /* NO_ARG_ARRAY */
+ 
        echo_area_contents = message_buf;
        message_buf_print = 0;
        printbufidx = 0;

--8<--------8<--------8<--------8<--------8<--------8<--------8<------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads