From thomas@biostat.washington.edu  Fri Jul 25 19:45:57 1997
From: thomas@biostat.washington.edu (Thomas Lumley)
Date: Fri, 25 Jul 1997 11:45:57 -0700 (PDT)
Subject: R-alpha: new version
In-Reply-To: <199707250857.KAA17779@aragorn.ci.tuwien.ac.at>
Message-ID: <Pine.SUN.3.95.970725113626.3738E-100000@zen>

I have traced down the segfault that Venkat and I reported with C
routines. It is in S_alloc, which explains why only some routines cause
problems.

The problem is that size is declared but never set, resulting in
(xxgdb) print size
$10 = 1081754432

I don't know precisely what is happening here but my guess is that we
should have size=nelem*eltsize/sizeof(char). 

(Q: Is it necessary or even true that eltsize/sizeof(char) is always an
integer?) 

char *S_alloc(long nelem, int eltsize)
{
	unsigned int i, size;
	char *p = R_alloc(nelem, eltsize);
	for(i=0 ; i<size; i++)
		p[i] = 0;
	return p;
}


Thomas Lumley
------------------------------------------------------+------
Biostatistics		: "Never attribute to malice what  :
Uni of Washington	:  can be adequately explained by  :
Box 357232		:  incompetence" - Hanlon's Razor  :
Seattle WA 98195-7232	:				   :
------------------------------------------------------------

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


R-alpha: new version
Thomas Lumley