Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Re: libcurses and patches for 4.0
@ 1999-08-10  4:00 Barry Andreasen
  0 siblings, 0 replies; 4+ messages in thread
From: Barry Andreasen @ 1999-08-10  4:00 UTC (permalink / raw)


After working with Jon on this we have isolated the problem and I
thought that posting the results would be beneficial to other developers
as well.  I tried to post this reply yesterday, but somehow I goofed
since I don't see it, but if this is a second, please excuse the
redundancy.

In debugging the application Jon mentioned, it was found that the segv
was occurring in the application code, when it tried to write to an
invalid address.  Further investigation found that address was expected
to be to a global application variable, but the variable involved was
also declared as a global variable with a similar definition in the
curses library.  While the application source code included a definition
for the pointer, the linker and loader had resolved the address to be in
the library memory allocation.

After some research we learned that during compilation, the linker
categorizes each variable.  In the general case, the linker, when it
finds new declarations will allocate space in the local memory region
and categorize the variable as an 'allocated common' (odump -Dtv
libcurses.so).  When the curses library was built, this variable was
unique and therefore generated an allocated region and became a GLOBAL
ACOMM.  However, when the linker finds an existing entry for a new
variable (from a library), it does not do the allocation, and enters the
variable as a simple common (COMM) and uses the offset to the existing
allocated space from the ACOMM variable (odump -Dgv <app.obj>).

Previous versions of the libcurses.so ignored this violation, and
fortunately functioned correctly, but the updated library versions
blocked this violation and uncovered the memory overwrite, causing the
application to segv.

Since the specification for the curses interface indicates that certain
variable names are reserved for the library implementation (this
variable falls into that category), the solution is rename the
application variable or force the local application declaration to do an
allocation in the application data space by including an assignment in
the declaration
 i.e. char *BC=NULL;


This will cause the linker to classify the variable as DATA and place it
in the application DATA space.  When the loader encounters the variable,
as data, it will use the local memory storage instead of writing to the
library memory area.
-b

In article <7ml487$lbg$1@nnrp1.deja.com>, jhitchcock@my-deja.com wrote:
> There are a lot of patches to libcurses available for 4.0, but it
seems that
> the libraries are in general incompatible with one another.
>
> We have a program that was built on 4.0D (without any patches) and it
runs
> OK on that system.  When run on a patched 4.0D it fails with "error -1
bad
> termcap".  When run on 4.0E it core dumps.
>
> Can anyone suggest how we can get a library on patched 4.0D, 4.0E,
4.0F,
> ... systems which is compatible with the original 4.0D library.  Or
does
> anyone know which is the "correct" library to link with to enable use
on
> future systems.
>
> The program is linked using the default shared library (-lcurses) and
it
> uses tgetent(), tgetflag(), tgetnum() and tgetstr() to get
capabilities:
>
> am bs hs mi ms pt xs sg ug li co ws ae al as bc bt cd ce cl cm cs dc
dl dm do ed ei
> fs ho ic im le ll nd se sf so sr te ti
> ts uc ue up us vb ke ks ve vi bt kd kh kl kr ku CC k[0-9] K[0-9]
l[0-9] L[0-9]
>
> (I know these functions are marked "TO BE WITHDRAWN" in the Single
UNIX
> Specification, but they are there, and they work on almost all
Unixes.)
>
> The patches I know of are:
> Digital UNIX 4.0D patches 374.00 374.03 408.02
> Digital UNIX 4.0E patches 31.00 123.00 277.00 278.00
> Tru64 UNIX 4.0F patches 46.00 69.00
>
> Thanks,
>
> Jon Hitchcock





^ permalink raw reply	[flat|nested] 4+ messages in thread
* Dec C pecularity
@ 1999-06-09  4:00 Bernhard Reiter
  1999-06-11  4:00 ` Jeff Sullivan
  0 siblings, 1 reply; 4+ messages in thread
From: Bernhard Reiter @ 1999-06-09  4:00 UTC (permalink / raw)


While compiling mutt-0.95.6i on
	OSF1 V4.0 878 alpha
using 	DEC C V5.6-079 on Digital UNIX V4.0 (Rev. 878)
I encountered a difference between gnu c and Dec c.
Wheather this is a bug or not, I can't say, but at least it
is a pitfall.


Consider the following program, Dec C doesn't like the y definition:
	#include <stdio.h>

	char x[]="\
	Hi\n Here is more\n\
	Wolw\n";

	char y[]=("Hi there");

	int main(void){
		printf("%s",x);
		return 0;
	}

alpha1 mutt-0.95.6 166: gcc -pedantic -ansi -Wall probe.c
alpha1 mutt-0.95.6 167: cc probe.c
cc: Warning: probe.c, line 7: In the initializer for y[0], "("Hi there")" has a
larger data size than "signed char".  Assignment may result in data loss.
char y[]=("Hi there");
---------^
cc: Warning: probe.c, line 7: In the initializer for y[0], "("Hi there")" of typ
e "pointer to signed char", is being converted to "signed char".
char y[]=("Hi there");
---------^
cc: Error: probe.c, line 7: In the static initialization, the address cannot be
converted to the destination type.
char y[]=("Hi there");
---------^
alpha1 mutt-0.95.6 168: cc -std1 probe.c
cc: Error: probe.c, line 7: In the initializer for y a required set of braces is
 missing.
char y[]=("Hi there");
---------^

Cheers,
	Bernhard

-- 
Research Assistant, Geog Dept UM-Milwaukee, USA.         (www.uwm.edu/~bernhard)
Funding/Promoting Association for a Free Informational Infrastructure (ffii.org)



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-08-10  4:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-08-10  4:00 libcurses and patches for 4.0 Barry Andreasen
  -- strict thread matches above, loose matches on Subject: below --
1999-06-09  4:00 Dec C pecularity Bernhard Reiter
1999-06-11  4:00 ` Jeff Sullivan
1999-06-13  4:00   ` Tobias Ernst
1999-06-14  4:00     ` Peter da Silva
1999-06-26  4:00       ` Tobias Ernst
1999-06-29  4:00         ` Charles M Richmond
1999-07-13  4:00           ` Tobias Ernst
1999-07-14  4:00             ` T.E.Dickey
1999-07-15  4:00               ` libcurses and patches for 4.0 jhitchcock
1999-07-16  4:00                 ` T.E.Dickey
1999-08-10  4:00                 ` b_andreasen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox