Bug 178133 - Remove environ variable in lib/signature.c for IRIX
Remove environ variable in lib/signature.c for IRIX
Status: CLOSED UPSTREAM
Product: Fedora
Classification: Fedora
Component: rpm (Show other bugs)
rawhide
mips32 Linux
medium Severity medium
: ---
: ---
Assigned To: Paul Nasrat
Mike McLean
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-01-17 17:52 EST by The Written Word
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-01-20 16:06:24 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch (509 bytes, patch)
2006-01-17 17:53 EST, The Written Word
no flags Details | Diff

  None (edit)
Description The Written Word 2006-01-17 17:52:00 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.0.7-1.1.fc3 Firefox/1.0.7

Description of problem:
On IRIX, environ is a weak symbol. There is no extern declaration for
it anywhere in /usr/include, so system.h does:
  #ifdef __APPLE__
  #include <crt_externs.h>
  #define environ (*_NSGetEnviron())
  #else
  extern char ** environ;
  #endif /* __APPLE__ */
   
However, lib/signature.c has:
  #if !defined(__GLIBC__) && !defined(__APPLE__)
  char ** environ = NULL;
  #endif

So, the SGI C compiler creates an entry in lib/signature.o for
environ. This causes problems in lib/psm.c:
  /* XXX Don't mtrace into children. */
  unsetenv("MALLOC_CHECK_");

unsetenv() isn't available on IRIX so the substitute copy in
misc/setenv.c is used instead:
  void
  unsetenv (name)
       const char *name;
  {
    const size_t len = strlen (name);
    char **ep;

    LOCK;

    ep = __environ;
    while (*ep != NULL)
    ...

Unfortunately, at this opint, ep = NULL and *ep gives a SEGV, causing package installation to fail. What's odd is that rpm -Uv works because ep != NULL. When installing via YUM, using the Python RPM module, ep == NULL causing installation to fail.

Version-Release number of selected component (if applicable):
CVS HEAD

How reproducible:
Always

Steps to Reproduce:
1. yum install [package]

Additional info:
Comment 1 The Written Word 2006-01-17 17:53:21 EST
Created attachment 123339 [details]
Patch
Comment 2 Jeff Johnson 2006-01-19 16:35:37 EST
I don't have access to irix, hence am entirely unable to test.

Can you supply a patch?
Comment 3 Jeff Johnson 2006-01-19 16:37:55 EST
Ah yes, saw the patch right after I hit return.

Can you supply a better patch that doesn't just rip out otherwise known working code?

Comment 4 The Written Word 2006-01-19 16:59:07 EST
__GLIBC__ is defined on Linux so the code is never executed. What's more, from
system.h:
#if !defined(__GLIBC__) && !defined(__LCLINT__)
#ifdef __APPLE__
#include <crt_externs.h>
#define environ (*_NSGetEnviron())
#else
extern char ** environ;
#endif /* __APPLE__ */
#endif
#endif

So, on systems where __GLIBC__ is not defined, you get:
  extern char ** environ;  // system.h
  char ** environ = NULL;  // lib/signature.c

I doubt you can decide what the compiler will do in this case.
Comment 5 Jeff Johnson 2006-01-20 15:04:55 EST
The patch needs to be conditionalized on some non-gcc irix compiler-peculier constants.

Private inquiries indicate that an additional
    ... && (!defined(sgi) || (_COMPILER_VERSION < 0720))
conditioning might do the trick.

Can you confirm or suggest a better test?
Comment 6 The Written Word 2006-01-20 15:23:52 EST
Well, RPM won't build on IRIX out-of-the box. The patch was to fix a problem we
found with RPM 4.2.4 that we forward-ported to HEAD (many more patches are
required to get RPM building on non-Linux boxes).

#if !defined(__GLIBC__) && !defined(__APPLE__)
char ** environ = NULL;
#endif

The pre-processor define __sgi is available to SGI cc and GCC. So, if you really
want this code left in, you can:
  #if !defined(__GLIBC__) && !defined(__APPLE__) && !defined(__sgi)
  char ** environ = NULL;
  #endif

I cannot imagine any platform where the code above does any good though. We
removed it and have RPM 4.2.4 working fine on Solaris, HP-UX, IRIX, Tru64 UNIX,
AIX, and Redhat Linux.
Comment 7 Jeff Johnson 2006-01-20 15:30:03 EST
Thanks, that's the confirmation I needed. I have a dim memory of HPUX? AIX? needing the
conditionalizing, but have long since forgoytten the details.

BTW, send a ptr to your other platform patches to <rpm-devel@lists.dulug.duke.edu> and I will try to 
integrate into rpm main stream.

What stops me is lack of access to the platforms, not anything else.

Hmmm, I also don't remember ever releasing rpm-4.2.4, but perhaps I've forgotten ... checking ...
yes, there is no rpm-4_2_4-relase tag in rpm cvs at cvs.rpm.org.
Comment 8 The Written Word 2006-01-20 15:34:59 EST
Oops, I meant 4.2.3. Though, when we made our changes, it was against the
rpm-4_2 branch.

IRIX was the only platform with the SEGV. However, we disabled the code on all
platforms in the previous message.

I submitted the IRIX patch to rpm-devel but didn't get any feedback so created
this bug report.
Comment 9 Jeff Johnson 2006-01-20 16:06:24 EST
rpm-devel still the place for non-RH patches. If you have other patcches, I'll try to get them merged into 
rpm sources.

Fixed in CVS, will be in rpm-4.4.5-0.7 when built.

Note You need to log in before you can comment on or make changes to this bug.