Bug 178133 - Remove environ variable in lib/signature.c for IRIX
Summary: Remove environ variable in lib/signature.c for IRIX
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: rawhide
Hardware: mips32
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Paul Nasrat
QA Contact: Mike McLean
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-01-17 22:52 UTC by The Written Word
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-01-20 21:06:24 UTC
Type: ---
Embargoed:


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

Description The Written Word 2006-01-17 22:52:00 UTC
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 22:53:21 UTC
Created attachment 123339 [details]
Patch

Comment 2 Jeff Johnson 2006-01-19 21:35:37 UTC
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 21:37:55 UTC
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 21:59:07 UTC
__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 20:04:55 UTC
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 20:23:52 UTC
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 20:30:03 UTC
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.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 20:34:59 UTC
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 21:06:24 UTC
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.