delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/02/09/01:18:30

Date: Wed, 9 Feb 94 14:30:16 JST
From: Stephen Turnbull <turnbull AT shako DOT sk DOT tsukuba DOT ac DOT jp>
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: found cause of segmentation violations in string functions in Imake

I was having problems with segmentation violations arising in Imake
(the X Windows portable makefile maker).
    I thought it was caused by a statement of the form

	     fprintf (stderr, "Can't open a pipe.", "");

but it turned out that I got caught by the fact that symify often
points to the statement *following* the bomb.  The bomb actually was

	   fprintf (stderr, "%s: ", sys_errlist [ errno ]);

and of course someone had added some extra error numbers to errno.h
without adding descriptive strings to sys_errlist in syserr.c.
    It has been mentioned to me by several people, and I think copied
to the list, that the string functions in the library don't catch this
kind of thing.  According to Harbison and Steele (2e, so it may not be
up to date), checking validity of pointers passed to the string
library is the programmer's responsibility, so the string functions
*should not* be patched.  A couple of posts have mentioned this kind
of problem recently (although they are not related to the sys_errlist
as I recall); this may be the kind of thing they are running into.
    Make sure your arrays are correctly dimensioned!
    I will patch syserr.c with reasonable strings (RSN, that's why I'm
posting this now) and post it.
    --Steve

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019