Subject: Re: -current problems
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Todd Vierling <tv@NetBSD.ORG>
List: current-users
Date: 02/18/1998 13:04:04
On Wed, 18 Feb 1998, der Mouse wrote:

: > Paul was talking about *the size of the object sys_errlist[]*, not
: > the `size' represented by sys_nerr.  Only enough space for the old
: > sys_errlist[] is allocated in the executable's data segment; the new
: > definition is too long and ends up overwriting other objects in the
: > data segment.
: I *thought* that shared libraries had their own data segments, loaded
: at the same time as the library's text segment; certainly SunOS ones
: do.  Under this paradigm, no space is allocated in the executable for
: things like sys_errlist[]; it all comes from the library.  (Of course,
: nonshared libraries do get space allocated, but it's filled in at the
: same time and doesn't change afterwards, so the issue doesn't arise.)

This is what I thought too; however, compiling a test program linked against
1.3 libraries that prints any of the new error messages by explicit number
bombs, even though sys_nerr is the correct (larger) number.  Note that in my
test, a program which has no need to display the "new" messages does not
bomb out and functions just as it should.

Even stranger, I created a sample test case with my own array in a shlib and
a test program that printf'd elements 0, 16, 32, 48, 64, ... 1008.  I
started the array with 512 elements, and the program dumped nowhere; it just
printed (null) pointers, and dumped nowhere accessing the array.  Adding
another 512 elements worked fine.  Eh?!  Perhaps the sys_errlist[] table is
unluckily crossing a page boundary or somesuch?

[Granted, shouldn't the entire array be a *text* reference (not data) since
both the array of pointers and the data pointed to are declared const?  I
suppose we don't put const strings in the text segment, alas.]

===== Todd Vierling (Personal; Bus.
== "There's a myth that there is a scarcity of justice to go around, so
== that if we extend justice to 'those people,' it will somehow erode the
== quality of justice everyone else receives."  -- Maria Price