Mailing List Archive

Two small bugs in Apache 0.8.4 (fwd)
Re: Two small bugs in Apache 0.8.4 (fwd) [ In reply to ]
In reply to Robert S. Thau who said
>
> Um, David, I only see *one* bug listed there (problems compiling on SunOS
> with GNU libs)...
>
> Sigh... I really would like to release 0.8.7 unless there is some
> compelling reason not to, and while hanging on restarts is compelling,
> I don't think this is. (I agree with some of the comments, sympathize
> with the situation, etc., but given the ease of the workaround --- all
> you really *need* to do is to change the #if on conf.h to #ifdef NOTDEF,
> and compile without -Wall --- and the fact that anyone using the GNU C
> library instead of the vendor libraries is likely to be competent to
> do that, I can live with it for a beta).

This is hardly a bug that should prevent a beta release being spun, in
fact, this is exactly the sort of things beta release are supposed to
uncover.

As to the actual problem though, I agree that apache should not declare
prototypes for library functions. The OS should do that and if it doesn't
then it's a bug in the OS. Including the correct headers should declare
the relevant prototypes for any library functions used.


--
Paul Richards, Bluebird Computer Systems. FreeBSD core team member.
Internet: paul@FreeBSD.org, http://www.freebsd.org/~paul
Phone: 0370 462071 (Mobile), +44 1222 457651 (home)
Re: Two small bugs in Apache 0.8.4 (fwd) [ In reply to ]
Um, David, I only see *one* bug listed there (problems compiling on SunOS
with GNU libs)...

Sigh... I really would like to release 0.8.7 unless there is some
compelling reason not to, and while hanging on restarts is compelling,
I don't think this is. (I agree with some of the comments, sympathize
with the situation, etc., but given the ease of the workaround --- all
you really *need* to do is to change the #if on conf.h to #ifdef NOTDEF,
and compile without -Wall --- and the fact that anyone using the GNU C
library instead of the vendor libraries is likely to be competent to
do that, I can live with it for a beta).

rst
Re: Two small bugs in Apache 0.8.4 (fwd) [ In reply to ]
Rob wrote:
> System: SunOS 4.1.4; Sparc 10/51; Apache 0.8.4
>
> 1) conf.h:
> > #if defined(SUNOS4) && !defined(__SUNPRO_C)
> > /* Prototypes needed to get a clean compile with gcc -Wall.
> > * Believe it or not, these do have to be declared, at least on SunOS,
> > * because they aren't mentioned in the relevant system headers.
> > * Sun Quality Software. Gotta love it.
>
> I have the GNU libraries installed, and get a bunch of:
> > conf.h:361: conflicting types for `strcasecmp'
> > /usr/GNU/lib/gcc-lib/sparc-sun-sunos4.1.3/2.6.0/include/string.h:32:
> > previous declaration of `strcasecmp'
> > conf.h:362: conflicting types for `strncasecmp'
> > /usr/GNU/lib/gcc-lib/sparc-sun-sunos4.1.3/2.6.0/include/string.h:34:
> > previous declaration of `strncasecmp'
> etc.
> > make: *** [alloc.o] Error 1
>
> I had to comment out that part of conf.h to get things to compile.
> Perhaps a check to see if the GNU includes are there before declaring
> in conf.h?

Yuk yuk yuk. Putting prototypes for library routines is the wrong thing
to do _especially_ if the prototypes are incorrect.

The only occasion that prototyping library routines can be safe is if the
it is done for a historic, unchanging operating system. You might think
that SunOS would fit this, but in fact it is SunOS + gcc that must be
frozen. Gcc provides prototypes for some of the library routines, but
precisely which routines seems to be version dependent.

Fixes:
1. #include <strings.h>. This provides some missing prototypes.
2. #define __USE_FIXED_PROTOTYPES__ before #including the system headers.
This causes the headers that gcc has fixed (stdio.h etc.) to contain
more prototypes.

Unfortunately 1+2 do not provide prototypes for all the routines needed by
apache. The patch below implements 1+2, and supplies corrected versions of the
remaining missing prototypes. It seems to work under gcc 2.6 and 2.7
(SunOS 4.1.2).

I would suggest dropping _all_ the prototypes from the header files, and
just relying on fixes 1+2 (above). If you want to get rid of the -Wall
warnings, upgrade to Solaris 2.

Seriously though, leaving out the prototypes provokes compilation warnings
only with -Wall. Whereas including the prototypes runs the risk of compilation
failure under some (maybe future) OS/gcc versions.

David.


------------------------------ conf.patch ------------------------------
*** conf.h.orig Fri Aug 4 00:59:50 1995
--- conf.h Fri Aug 4 18:06:31 1995
***************
*** 71,76 ****
--- 71,83 ----
#undef NO_SETSID
char *crypt(char *pw, char *salt);
#define JMP_BUF sigjmp_buf
+ #if defined(__GNUC__)
+ /* Prototypes needed to get a clean compile with gcc -Wall.
+ * This #define causes the gcc headers to show the prototypes that
+ * gcc invented.
+ */
+ #define __USE_FIXED_PROTOTYPES__
+ #endif

#elif defined(SOLARIS2)
#undef BSD
***************
*** 359,413 ****
* because they aren't mentioned in the relevant system headers.
* Sun Quality Software. Gotta love it.
*/

! int getopt (int, char **, char *);

! int strcasecmp (char *, char *);
! int strncasecmp (char *, char *, int);
! int toupper(int);
! int tolower(int);
!
! int printf (char *, ...);
! int fprintf (FILE *, char *, ...);
! int fputs (char *, FILE *);
! int fread (char *, int, int, FILE *);
! int fwrite (char *, int, int, FILE *);
! int fflush (FILE *);
! int fclose (FILE *);
! int ungetc (int, FILE *);
! int _filbuf (FILE *); /* !!! */
! int _flsbuf (unsigned char, FILE *); /* !!! */
! int sscanf (char *, char *, ...);
! void setbuf (FILE *, char *);
! void perror (char *);
!
! time_t time (time_t *);
! int strftime (char *, int, char *, struct tm *);
!
! int initgroups (char *, int);
! int wait3 (int *, int, void*); /* Close enough for us... */
! int lstat (const char *, struct stat *);
! int stat (const char *, struct stat *);
! int flock (int, int);
! int getwd (char *);
! #ifndef NO_KILLPG
! int killpg(int, int);
! #endif
! int socket (int, int, int);
! int setsockopt (int, int, int, const char*, int);
! int listen (int, int);
! int bind (int, struct sockaddr *, int);
! int connect (int, struct sockaddr *, int);
! int accept (int, struct sockaddr *, int *);
! int shutdown (int, int);

! int getsockname (int s, struct sockaddr *name, int *namelen);
! int getpeername (int s, struct sockaddr *name, int *namelen);
! int gethostname (char *name, int namelen);
! void syslog (int, char *, ...);
! char *mktemp (char *);
!
! #include <stdarg.h>
! long vfprintf (FILE *, char *, va_list);
!
#endif
--- 366,392 ----
* because they aren't mentioned in the relevant system headers.
* Sun Quality Software. Gotta love it.
*/
+ #include <strings.h>
+ extern int strncasecmp (const char *, const char *, int); /* annoying */
+ extern int toupper(int);
+ extern int tolower(int);

! extern time_t time (time_t *);

! extern int initgroups (const char *, int);
! extern char *getwd (char *);
! extern int killpg(int, int);
! extern int socket (int, int, int);
! extern int setsockopt (int, int, int, const char*, int);
! extern int listen (int, int);
! extern int bind (int, const struct sockaddr *, int);
! extern int connect (int, struct sockaddr *, int);
! extern int accept (int, struct sockaddr *, int *);
! extern int shutdown (int, int);

! extern int getsockname (int s, struct sockaddr *name, int *namelen);
! extern int getpeername (int s, struct sockaddr *name, int *namelen);
! extern int gethostname (char *name, int namelen);
! extern void syslog (int, char *, ...);
! extern char *mktemp (char *);
#endif
------------------------------ conf.patch ------------------------------
Re: Two small bugs in Apache 0.8.4 (fwd) [ In reply to ]
>Sigh... I really would like to release 0.8.7 unless there is some
>compelling reason not to, and while hanging on restarts is compelling,
>I don't think this is. (I agree with some of the comments, sympathize
>with the situation, etc., but given the ease of the workaround --- all
>you really *need* to do is to change the #if on conf.h to #ifdef NOTDEF,
>and compile without -Wall --- and the fact that anyone using the GNU C
>library instead of the vendor libraries is likely to be competent to
>do that, I can live with it for a beta).

I thought 0.8.7 didn't hang on restarts.

The problem is _not_ the GNU C library. It is with the header files with the
GNU C _compiler_ and the fact that the current prototypes in conf.h are
_wrong_.

Of course, nobody uses SunOS 4 anyway...

David.