Subject: rpm crashing on RH 7.0 indy

From: Karel van Houten <[email-masked]>
Date: Sat, 17 Mar 2001 11:51:19 +0100 (MET)

Hi all,

I hope someone can help me with this problem...

I've installed an Indy with Ralfs Redhat/test-7.0 packages.
Most things work OK, but rpm itself crashes when installing
a package. Here is a trace of what happens:

(gdb) run
Starting program: /usr/src/redhat/BUILD/rpm-4.0/rpm -ihv /cdrom/mips/XFree86-dev
el-4.0.1-1lm.mips.rpm 

Program received signal SIGSEGV, Segmentation fault.
_dl_lookup_versioned_symbol (undef_name=0x2affa6af "strcpy", 
    undef_map=0x10075330, ref=0x7fff9818, symbol_scope=0x1007554c, 
    version=0x100756b0, reloc_type=3, explicit=0) at do-lookup.h:52
52      do-lookup.h: No such file or directory.
(gdb) bt
#0  _dl_lookup_versioned_symbol (undef_name=0x2affa6af "strcpy", 
    undef_map=0x10075330, ref=0x7fff9818, symbol_scope=0x1007554c, 
    version=0x100756b0, reloc_type=3, explicit=0) at do-lookup.h:52
#1  0x5c30e4 in _dl_relocate_object () at ../sysdeps/mips/dl-machine.h:684
#2  0x5b6a40 in dl_open_worker (a=0x1007554c) at dl-open.c:316
#3  0x5b4a18 in _dl_catch_error (objname=0x7fff9a38, errstring=0x7fff9a3c, 
    operate=0x5b6470 <dl_open_worker>, args=0x7fff9a28) at dl-error.c:149
#4  0x5b6ca0 in _dl_open (file=0x7fff9c10 "libnss_nisplus.so.2", mode=1, 
    caller=0x0) at dl-open.c:380
#5  0x58882c in do_dlopen (ptr=0x7fff9bf0) at dl-libc.c:78
#6  0x5b4a18 in _dl_catch_error (objname=0x7fff9bc0, errstring=0x7fff9bc4, 
    operate=0x5887ec <do_dlopen>, args=0x7fff9bf0) at dl-error.c:149
#7  0x5887a4 in dlerror_run (operate=0x1007554c, args=0x0) at dl-libc.c:42
#8  0x58893c in __libc_dlopen (__name=0x1007554c "\020\b\023\230\020\b\031 ")
    at dl-libc.c:104
#9  0x57d1d0 in __nss_lookup_function (ni=0x10080b80, 
    fct_name=0x5e3be0 "getpwnam_r") at nsswitch.c:333
#10 0x57c560 in __nss_lookup (ni=0x7ffff2b0, fct_name=0x5e3be0 "getpwnam_r", 
    fctp=0x7ffff2b4) at nsswitch.c:148
#11 0x57e544 in __nss_passwd_lookup (ni=0x7ffff2b0, 
    fct_name=0x5e3be0 "getpwnam_r", fctp=0x7ffff2b4) at XXX-lookup.c:68
#12 0x56d7d0 in __getpwnam_r (name=0x5cc34c "root", resbuf=0x10018c08, 
    buffer=0x10080520 "\020", buflen=1024, result=0x7ffff308)
    at ../nss/getXXbyYY_r.c:159
#13 0x56c9bc in getpwnam (name=0x5cc34c "root") at ../nss/getXXbyYY.c:127
#14 0x42753c in installBinaryPackage (rootdir=0x1004de50 "/", db=0x1004a688, 
    fd=0x100a2bb8, h=0x10088890, flags=0, notify=0x438fa0 <showProgress>, 
    notifyData=0x12, pkgKey=0x7ffff9f6, actions=0x1006edb8, sharedList=0x0, 
    scriptFd=0x0) at install.c:941
#15 0x449c20 in rpmRunTransactions (ts=0x1004dde8, 
    notify=0x438fa0 <showProgress>, notifyData=0x12, okProbs=0x0, 
    newProbs=0x7ffff6c4, transFlags=0, ignoreSet=0) at transaction.c:1701
#16 0x439c4c in rpmInstall (rootdir=0x5c917c "/", fileArgv=0x1001faf8, 
    transFlags=0, interfaceFlags=2, probFilter=0, relocations=0x0)
    at rpminstall.c:370
#17 0x406a2c in main (argc=3, argv=0xffffffff) at rpm.c:1133
#18 0x53599c in __libc_start_main (main=0x404090 <main>, argc=3, 
    ubp_av=0x7ffff8d4, init=0x4000f8 <_init>, fini=0x5c6880 <_fini>, 
    rtld_fini=0, stack_end=0x7ffff8b0) at ../sysdeps/generic/libc-start.c:111

This is a static rpm binary, so I don't understand why it tries
do dynaload anything at all...

Thanks in advance,
-- 
Karel van Houten

---

From: David Jez <[email-masked]>
Date: Sat, 17 Mar 2001 16:47:26 +0100

> do dynaload anything at all...
  Hi,

Ooops, i think: haven't you got broken rpm? Have you downloaded the rpm
complete? Try checksum or md5.

> Thanks in advance,
Hope you will be succeded,
Dave
-- 
-------------------------------------------------------
  David "Dave" Jez                Brno, CZ, Europe
 E-mail: [email-masked]
PGP key: finger [email-masked]
---------=[ ~EOF ]=------------------------------------

---

From: Keith M Wesolowski <[email-masked]>
Date: Sat, 17 Mar 2001 09:39:19 -0800

> complete? Try checksum or md5.

That's not the problem.  The problem is that static binaries which use
libdl used to be (and perhaps still are) broken.  The reason it's
using libdl is that the nss libraries are never truly static, unless
you compile glibc with a special non-recommended option.  I have
indications that this may be fixed in glibc 2.2.2 using my current
toolchain, but my information is not complete.

-- 
Keith M Wesolowski <[email-masked]> http://foobazco.org/~wesolows
------(( Project Foobazco Coordinator and Network Administrator ))------
"I should have crushed his marketing-addled skull with a fucking bat."

---

From: Carsten Langgaard <[email-masked]>
Date: Thu, 22 Mar 2001 09:40:57 +0100

Thanks Karel for the RH 7.0 tarball.
I have install it and it seems to work fine, except for the RPM stuff.
Have you or anyone else managed to get rpm to work ?
We really need it to get going.

/Carsten

--
_    _ ____  ___   Carsten Langgaard   Mailto:[email-masked]
|\  /|||___)(___   MIPS Denmark        Direct: +45 4486 5527
| \/ |||    ____)  Lautrupvang 4B      Switch: +45 4486 5555
  TECHNOLOGIES     2750 Ballerup       Fax...: +45 4486 5556
                   Denmark             http://www.mips.com

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Tue, 27 Mar 2001 20:24:12 +0200 (MET DST)

> toolchain, but my information is not complete.

 Glibc is fine; it's the kernel that needs a fix (I've sent it here
already once or twice).  We might possibly consider putting a workaround
into glibc as well.

 The problem is mmap() fails if a non-zero preferred address is given but
the space is already occupied and no space *above* is available (space
below is not taken into account).  A glibc workaround might be to call
mmap() again with no preferred address specified this time. 

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email-masked], PGP key available        +

---

From: Carsten Langgaard <[email-masked]>
Date: Wed, 28 Mar 2001 09:06:49 +0200

> already once or twice).  We might possibly consider putting a workaround

Have the kernel fix made it into the CVS.
If not, could you please resent it.

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Wed, 28 Mar 2001 15:50:34 +0200 (MET DST)

> If not, could you please resent it.

 I do not consider it clean enough for inclusion into the official kernel
at this stage.  It works, though.

 When appropriately cleaned up, I'll submit it to Linus as it's not
MIPS-specific and affects all systems -- mmap() fails equally badly on an
i386, for example.  No time to work on the patch at the moment, sorry.

patch-2.4.0-test4-mmap-3
diff -u --recursive --new-file linux-2.4.0-test4.macro/mm/mmap.c linux-2.4.0-test4/mm/mmap.c
--- linux-2.4.0-test4.macro/mm/mmap.c	Sun Jul 16 22:27:29 2000
+++ linux-2.4.0-test4/mm/mmap.c	Tue Jul 25 05:06:21 2000
@@ -175,7 +175,7 @@
 	if ((len = PAGE_ALIGN(len)) == 0)
 		return addr;
 
-	if (len > TASK_SIZE || addr > TASK_SIZE-len)
+	if (len > TASK_SIZE || ((flags & MAP_FIXED) && (addr > TASK_SIZE - len)))
 		return -EINVAL;
 
 	/* offset overflow? */
@@ -356,20 +356,31 @@
 unsigned long get_unmapped_area(unsigned long addr, unsigned long len)
 {
 	struct vm_area_struct * vmm;
+	int pass = 0;
 
 	if (len > TASK_SIZE)
 		return 0;
-	if (!addr)
-		addr = TASK_UNMAPPED_BASE;
-	addr = PAGE_ALIGN(addr);
-
-	for (vmm = find_vma(current->mm, addr); ; vmm = vmm->vm_next) {
-		/* At this point:  (!vmm || addr < vmm->vm_end). */
-		if (TASK_SIZE - len < addr)
-			return 0;
-		if (!vmm || addr + len <= vmm->vm_start)
-			return addr;
-		addr = vmm->vm_end;
+
+	while (1) {
+		if (!addr)
+			addr = TASK_UNMAPPED_BASE;
+		addr = PAGE_ALIGN(addr);
+
+		for (vmm = find_vma(current->mm, addr); ; vmm = vmm->vm_next) {
+			/* At this point:  (!vmm || addr < vmm->vm_end). */
+			if (TASK_SIZE - len < addr) {
+				if (pass > 0)
+					return 0;
+				else {
+					pass = 1;
+					addr = 0;
+					break;
+				}
+			}
+			if (!vmm || addr + len <= vmm->vm_start)
+				return addr;
+			addr = vmm->vm_end;
+		}
 	}
 }
 #endif