Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: b_andreasen@my-deja.com
Subject: Re: libcurses and patches for 4.0
Date: 1999/08/10	[thread overview]
Message-ID: <7opga1$f7e$1@nnrp1.deja.com> (raw)
In-Reply-To: 7ml487$lbg$1@nnrp1.deja.com

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
> Uniplex Ltd, 126 Hempstead Road, Kings Langley,
> Herts, WD4 8AL, U.K.
> E-mail Jon.Hitchcock@uniplex.co.uk, Tel +44 (0)
> 1923 299718, Fax +44 (0)
> 1923 299700
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.



  parent reply	other threads:[~1999-08-10  4:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-13  4:00             ` Kevin Oberman
1999-07-13  4:00             ` Charles M Richmond
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 message]
1999-07-16  4:00               ` Dec C pecularity Tobias Ernst
1999-07-18  4:00                 ` T.E.Dickey
1999-07-14  4:00         ` T.E.Dickey
1999-06-22  4:00     ` Jeff Sullivan
1999-06-22  4:00       ` Jeff Sullivan
  -- strict thread matches above, loose matches on Subject: below --
1999-08-10  4:00 libcurses and patches for 4.0 Barry Andreasen
read-only archive

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